Hi, i have created a drop down list login page, that goes to the database to get the username, and then a validate_login page, which either takes you to good_login.php or bad_login.php.
But when i click on the user, and type in the password (correct), it displays a blank screen on the validate_login page. If i enter a wrong password, it also doesnt go to the database
My code for the login.php is
<?php
$sql = "SELECT real_name FROM jtrs_user ORDER BY id";
$connection = mysql_connect("localhost:3306", "", "") or die ("Couldn't connect to server.");
$db = mysql_select_db("JTRS") or die ("Unable to select database.");
$sql_result = mysql_query($sql) or die("Couldn't execute query.");
echo "<table width=760 border=0 align=center>";
echo "<tr>
<td colspan=2><p align=center><b><font color=\"#330066\">Please select your username from the list below.</font></b></p></td>
</tr>";
echo "<tr>
<td width=382>
<div align=right><font color=\"#330066\"><b>Username</b></font></div>
</td>
<td valign=top>
<select name=\"sel_record\">
<option value=\"\"> -- Select an Item -- </option>";
while ($row = mysql_fetch_array($sql_result)) {
$real_name = $row["real_name"];
echo "
<option value=\"$real_name\">$real_name</option>";
}
echo "
</select>
</td>
</tr>";
echo "<tr>
<td width=382>
<div align=right><font color=\"#330066\"><b>Password</b></font></div>
</td>
<td width=447>
<div align=left><b><input type=\"Password\" name=\"$password\" size=20 maxlength=12></b></div>
</td>
</tr>";
echo "<tr>
<td width=382> </td>
<td width=447> </td>
</tr>";
echo "<tr>
<td width=382>
<div align=right><input type=\"image\" src=\"images/btn_enter.gif\" width=50 height=15></div>
</td>
<td width=447><div align=left><a href=\"javascript:document.login.reset();\"><img src=images/btn_cancel.gif width=50 height=15 border=0></a></div></td>
</tr>";
echo "</table>";
?>
which then goes to validate_login
<?php
switch( $do )
{
case "authenticate":
$connection = mysql_connect("localhost:3306","","") or die ("Couldn't connect to server.");
$db = mysql_select_db("JTRS") or die ("Unable to select database.");
$sql = "SELECT real_name FROM jtrs_user WHERE username='$real_name' and password='$password'";
$result = mysql_query($sql) or die ("Couldn't get results.");
$num = mysql_numrows($result);
if ($num == 1) {
include("good_login.php");
}
else if ($num == 0) {
unset($do);
include("bad_login.php");
}
}
?>
and then goes to the first page which displays a tasks page with peoples details of tasks they have to do.
How do i get the page to take me to the good_login.php and bad_login.php depending on correct password entered.
Thanks in advance.
Adam