In the included piece of code, I have made an administration panel for our County Directory. When a user logs-on, they will be able to choose from a number of options in a drop-down box...
When I choose an option (during testing) and click 'Submit', the page is directed to itself...It doesn't go anywhere....
But when I choose the option a second time, it directs to the correct page...
Why is this happening?
In my code, I am using sessions to set variables, and I suspect this may be the reason why I have to double-click...Any and all input is appreciated!!!
Thank you all in advance for your help!!!
Mike
<?php
session_start();
// If a session is not registered, execute this code
if ( !session_is_registered('username') or !session_is_registered('password') or !session_is_registered('department'))
{
// No session variables are registered, so register them
session_register('username');
session_register('password');
session_register('department');
}
if ($POST['username'] <> "" or $POST['password'] <> "" or $_POST['department'] <> "")
{
// The log-in form has been completed, because all the fields at least equal something
// Set the username and password to be from the form
$username = $HTTP_POST_VARS['username'];
$password = $HTTP_POST_VARS['password'];
$department = $HTTP_POST_VARS['department'];
}
if ($SESSION['username'] <> "" or $SESSION['password'] <> "" or $SESSION['department'] <> "")
{
// Session equals something, so use these values for the fields
$username = $SESSION['username'];
$password = $SESSION['password'];
$department = $SESSION['department'];
}
else
{
header("Location:dhl.htm");
}
// Error check the password field
if (empty($password))
{
$msg = "<font face='Arial' size='+1' color='red'>Your login has failed!</font><br>
<font face='Arial' size='+1' color='#4D50A3'>Enter your password!<br><br>
Click <a href='dhl.htm'>here</a> to log-in again.</font>";
}
else
{
// Connect to the database and display an appropriate message
if ($num != 0)
{
$msg = "<table width=65% cellspacing=0 cellpadding=0 border=0 bgcolor='#F7F7F7'>
<tr><td align='top'><font face='Arial' color='#4d50a3' size='+1'><center>
Welcome,<font face='Arial' color='black'> $username</font>, you are now logged in!</font></center></td></tr>
<tr><td><center><b>
<font face='Arial' color='black' size='2'>Choose an option to manage your department.</font>
</b></center></td></tr>
<tr><td><center><font size='-5' face='Arial'><a href='help.php'>HELP</a></font></center></td></tr>
<tr><td> </td></tr>
<tr><td><center>
<form action='$location' method='post'>
<select name='location'>
<option value='ap.php'>Add an employee profile</option>
<option value='up_pf.php'>Update an existing employee profile</option>
<option value='del_pf.php'>Delete existing employee profiles</option>
<option value='cr_rpt.php'>Create a custom department report</option>
<option value='import.php'>Import an MS spreadsheet</option>
</select>
<input type='submit' name='submit' value='Submit'>
</form>
</center>
</td></tr>
<tr><td> </td></tr>
<tr><td><center><font face='Arial' size='+1' color='#4D50A3'>Click <a href='tyalo.php'>HERE</a> to log-out.</center></td></tr>
</table>
";
}
else
{
$msg = "<table width=65% cellspacing=0 cellpadding=0 border=0 bgcolor='#F7F7F7'>
<tr><td align='top'><font face='Arial' color='red' size='+1'><center>
Login for $username has failed!</font><br><br><font face='Arial' size='+1'><u>Check these following tips:</u></font><br><br><li><font face='Arial' size='3'
color='#4D50A3'><b>Is your user name spelled correctly?</li><br><li>Did you select your correct department?</li><br><li>Did you forget your password?</b><br><font
face='Arial' size='-4'><a href='mailto:administation@luzernecounty.org'>Retrieve Your
Password</a></font></li></font><br><br><br><font face='Arial' size='+1' color='#4D50A3'>Click <a href='dhl.htm'>here</a> to log-in again!</font></center></td>
</tr>
</table>";
}
}
?>