I want to create login form
here is the code
// login.html
<html>
<head>
<title>Login</title>
</head>
<form name="Login" method="post" action="loginbackend.php">
Username : <input name="txtUname" type="text" id="Uname"><br />
Password : <input name="txtUpass" type="password" id="Upass"><br />
<input type="submit" name="Submit" value="Login">
</form>
</html>
// loginbackend.php
<?php
ob_start();
$dbhost = 'localhost';
$dbuser = 'root';
$dbpass = '123'; //root password
$dbname = 'login'; //database name
$tbl_name = 'user_passs'; //table name
// to connect to MYSQL
$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql');
// to connect to database
mysql_select_db($dbname);
// getting user name and password
$username = $_POST;
$userpass = $_POST;
$username = stripslashes($username);
$password = stripslashes($password);
$username = mysql_real_escape_string($username);
$password = mysql_real_escape_string($password);
// Firing the query
$check = "SELECT * FROM $tbl_name WHERE uname = $username AND upass = $userpass";
$result = mysql_query($check);
$count = mysql_num_rows($result);
if($count==1)
{
session_start();
session_register('authorized');
$_SESSION = true;
header("location:successful.php");
exit;
}
else
{
header("location:failed.html");
exit;
}
mysql_close($conn);
ob_end_flush();
?>
this code is not working. Can any 1 help me.