<?
ob_start();
$host="localhost"; // Host name
$username="root"; // Mysql username
$password="root"; // Mysql password
$db_name="243934"; // Database name
$tbl_name="account"; // Table name
// Connect to server and select databse.
mysql_connect("$host", "$username", "$password")or die(mysql_error());
mysql_select_db("$db_name")or die(mysql_error());
// username and password sent from form
$Username = $_POST['Username'];
$Password = $_POST['Password'];
// Check records from a table
$sql="SELECT * FROM $tbl_name WHERE Username='$Username' and
Password='$Password'";
$result=mysql_query($sql);
// Mysql_num_row is counting table row
// If result matched $Username and $password, table row must be 1 row
$count=mysql_num_rows($result);
// Register $Username, $password and redirect to file "login_success.php"
if($count==1){
session_register("Username");
session_register("Password");
header("location:login_success.php");
}
else {
echo "Wrong Username or Password";
}