Using Header to redirect ro a Login Page
I wrote this code as a simple login script. But I'm not sure about the
syntax. My PHP editor tells me there's an error with my attempt to
redirect to the main menu. I looked up the Header() function and it seems
to be typed the same way across the Internet. Any help?
<?php
ob_start();
$host="localhost"; // Host name
$username="xexink"; // Mysql username
$password="login1"; // Mysql password
$db_name="users_admin"; // Database name
$tbl_name="users"; // Table name
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
$loginusername=$_POST['myusername'];
$loginpassword=$_POST['mypassword'];
$loginusername = stripslashes($username);
$loginpassword = stripslashes($password);
$loginusername = mysql_real_escape_string($username);
$loginpassword = mysql_real_escape_string($password);
$sql="SELECT * FROM $tbl_name WHERE username='$loginusername';
$result=mysql_query($sql);
$count=mysql_num_rows($result);
if($count==1){
header("location:Main_Menu_User.html");
}
else {
echo "Wrong Username or Password";
}
ob_end_flush();
?>
No comments:
Post a Comment