CONNECT.PHP
$hostname="localhost";
$mysql_login="username";
$mysql_password="pass";
$db="login";
if (!($db = mysql_connect($hostname, $mysql_login , $mysql_password))) or die("Can't connect to mysql.");
else
{
if (!(mysql_select_db("$db",$db))) or die("Can't connect to db.");
}
?>
LOGIN.PHP
session_start();
if($_POST){
$_SESSION['username']=$_POST["username"];
$_SESSION['password']=$_POST["password"];
}
$result=mysql_query("select * from users
where username='" . $_SESSION['username'] . "' and password='" . $_SESSION['password'] . "'");
$num=mysql_num_rows($result);
if($num < 1){
echo "You are not authenticated. Please login.
";
exit;
}
?>
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment