Hi,
I've got this weird bug 🙂 In the following code I have a form with ACTION="http://localhost/portal/admin.php?action=staff&editStaff=1&display=1". It's hardcoded for testing purposes (instead of using $PHP_SELF). When the form is submitted, it sends me to "http://localhost/portal/admin?"
instead of the correct URL.
Any ideas? Thanks so very much in advance!
NOTE: this is an include, but I'm 100% sure that the previous code didn't muck it up (I viewed the parsed html source)
<?PHP
function printForm($infoType) //-start function: infoType is data from staff table e.g. staff_nick_name
{
global $PHP_SELF, $connection; //declare function globals
$query = Mysql_Query("SELECT * FROM staff", $connection);
$rows = Mysql_Num_Rows($query); //get number of $rows in table staff
echo("<SELECT disabled SIZE=\"$rows\">"); //-start disabled select to display data, $rows in height
for ($i=0; $i<$rows; $i++)
{
$j = Mysql_Result($query, $i, $infoType); //set $j = to whatever $infotype is
echo("<OPTION VALUE=\"$j\">$j"); //echo $j then loop back and display next
}
echo("</SELECT>"); //-end select
}
//-end function
/*if (isset($staff)) //if $staff ($staff is name of the selectable select area that displays id's)
{
$staff = $staff-1; //offset: arrays start at 0; auto_increments at 1
$query = Mysql_Query("SELECT * FROM staff", $connection);
$j = Mysql_Result($query, $staff, staff_nick_name); //set $j = to staff thats being edited
echo($j); //echo staff name
}*/
?>
<A HREF="http://localhost/portal/admin.php?action=staff&editStaff=1">Edit Staff</A> <!--display 1: edit staff 2: add staff 3: delete staff-->
<?PHP
echo("<br> before switch <br>"); //testing purpose-remove later ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////REMOVE/CHANGE
switch($editStaff) //-start switch switch shows edit/add/delete staff depending on what link is clicked in ?action=staff
{
case "1": //case 1: edit staff. HTML below will display a staff choice menu.
echo("after case 1");
?>
<b>Choose staff to edit:</b><br>
<table border="1" cellspacing="0" bgcolor="#636363" bordercolor="#DE9421">
<tr>
<td><br>
<FORM ACTION="http://localhost/portal/admin.php?action=staff&editStaff=1&display=1"> <!--refresh to ?staff, display means both menu and edit form staff must appear REMOVE/CHANGE-->
<?PHP
$query = Mysql_Query("SELECT * FROM staff", $connection);
$rows = Mysql_Num_Rows($query); //get number of rows from staff, set = to $rows
echo("<SELECT SIZE=\"$rows\">"); //-start select: print selectable staff_id area
for ($i=0; $i<$rows; $i++)
{
$j = Mysql_Result($query, $i, staff_id); //$j = staff_id
echo("<OPTION VALUE=\"$j\">$j"); //print $j and loop
}
?>
</td>
<td><font size="2">nick</font><br>
<?PHP printForm("staff_nick_name");?>
</td>
<td><font size="2">first_name</font><br>
<?PHP printForm("staff_first_name");?>
</td>
<td><font size="2">last_name</font><br>
<?PHP printForm("staff_last_name");?>
</td>
<td><font size="2">password</font><br>
<?PHP printForm("staff_password");?>
</td>
<td><font size="2">website</font><br>
<?PHP printForm("staff_website");?>
</td>
<td><font size="2">aff</font><br>
<?PHP printForm("affiliate_id");?>
</td>
<td><font size="2">bdate</font><br>
<?PHP printForm("staff_birthday");?>
</td>
<td><font size="2">gender</font><br>
<?PHP printForm("staff_gender");?>
</td>
<td><font size="2">city</font><br>
<?PHP printForm("staff_city");?>
</td>
<td><font size="2">province</font><br>
<?PHP printForm("staff_province");?>
</td>
<td><font size="2">country</font><br>
<?PHP printForm("staff_country");?>
</td>
<td><font size="2">icq</font><br>
<?PHP printForm("staff_icq");?>
</td>
<td><font size="2">aim</font><br>
<?PHP printForm("staff_aim");?>
</td>
<td><font size="2">yim</font><br>
<?PHP printForm("staff_yim");?>
</td>
<td><font size="2">msn</font><br>
<?PHP printForm("staff_msn");?>
</td>
<td><font size="2">comment</font><br>
<?PHP printForm("staff_comment");?>
</td>
<td><font size="2">image</font><br>
<?PHP printForm("staff_image");?>
</td>
<td><font size="2">email</font><br>
<?PHP printForm("staff_email");?>
</td>
<td><font size="2">updated</font><br>
<?PHP printForm("staff_last_updated");?>
</td>
<td><font size="2">joined</font><br>
<?PHP printForm("staff_joined");?>
</td>
</tr>
</table> <!--end displaying staff menu-->
<input type="Submit" value="Choose">
</form> <!--end select-->
<br>
<br>
<?PHP
if($display) //if $display is true, it means that the staff menu has already been submitted
{
echo("display is true!");
}
break;//-end choose and display menu
case "2":
break;
case "3":
break;
}//-end switch
?>
Thanks !
Ted