PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
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
<?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');
}
?>