Login code not working
Posted: Wed Jun 29, 2005 10:04 am
Hi all.....i'm trying to develope login page for my website..the code always seem to redirect to the failed login even though username and password are corect...can anybody please look trough my code
Code: Select all
<?php
session_start();
header("Cache-control: private");
$username = $POST['username'];
$_SESSION['username'] = $username;
$password = $POST['password'];
$_SESSION['password'] = $password;
$db = @mysql_connect('localhost', 'root') or die('could not connect to mysql db, the server return the error:'.mysql_error());
mysql_select_db("timelinesys",$db) or die('could not connect to mysql db, the server return the error:'.mysql_error());
$query = "select * from user where username='$username' and password='$password'";
$sql = mysql_query($query) or die(mysql_error());
$count = mysql_num_rows($sql);
if ($count == 1)
{
header('Location: menu.php');
}
else
{
header('Location: loginfailed.php');
}
?>