login page


#1

hi…its me again…i try to do login page for manager and user using same page…but…it didnt work…here i submit my code…
[php]
?php
if (isset($_POST[‘login’])){
if (!$_POST[‘username’] || !$_POST[‘userpassword’]) {
$display = " Please Insert User Name and Password";
}
else {
$check_user = “select * from employee where ID =
‘$_POST[username]’ && password = ‘$_POST[userpassword]’”;
$check_user_res = mysql_query($check_user) or die (mysql_error());

if (mysql_num_rows($check_user_res) < 1) //error login
{
$display = " *Invalid User Name and Password.";
}
else {
session_register(“sess_userid”);
session_register(“sessid”);
session_register(“username”);
session_register(“sessname”);

		$id = mysql_result($check_user_res, 0, "id");
		$name = mysql_result($check_user_res, 0, "fname");
		$_SESSION['username'] = $_POST['username'];
		$_SESSION['sessname'] = $name;
		$_SESSION['sessid'] = $id;
		$_SESSION["sess_userid"] = $id;

$sql = “select * from employee where ID = ‘$_SESSION[username]’”;
$query = mysql_query($sql) or die (mysql_error());
$result = mysql_fetch_assoc($query);
$r=$result[‘Designation’];

if ($r == manager) {
header (“Location: manager_page.php”);

}
else {
header (“Location: afterlog.php”);

}
}
}
}
?>
[/php]
it doesn’t separate the page…it only go to afterlog.php page…please help…thanks in advanced…


#2

What errors did you get?
What did you try to solve the problem?
Did you search the internet, and the PHP manual?

On a sidenote: your script is vulnerable to SQL injection. Click the link in my sig to read up on it.


#3
What errors did you get? What did you try to solve the problem? Did you search the internet, and the PHP manual?

No error…the page doesnt go the manager.php…it only go to afterlog.php
The coding u can see the coding…fully written by me…and try so many ways in coding…
yes i search in PHP manual…get some idea…and it helps me to do coding…


#4

Have you tried Debugging?

The code DOES generate errors. And I’d like to know what those errors are.