<?php
ob_start();
$host="127.0.0.1"; // Host name
$username="root"; // Mysql username
$password=""; // Mysql password
$db_name="register"; // Database name
$tbl_name="members"; // Table name
// Connect to server and select databse.
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
// username and password sent from signup form
$user=addslashes(htmlspecialchars($_POST['user']));
$pass=addslashes(htmlspecialchars($_POST['pass']));
$sql="SELECT * FROM $tbl_name WHERE user='$user' and pass='$pass'";
$result=mysql_query($sql);
// Mysql_num_row is counting table row
$count=mysql_num_rows($result);
// If result matched $myusername and $mypassword, table row must be 1 row
if($count==1){
// Register $user, $pass and redirect to file "loginpro.php"
$_SESSION['isl'] = true;
header("location:index.php");
}
else {
echo "Грешен Потребител или Парола!";
}
?>