PHP code for login with different subpages
Hello,
I would like to ask for help with PHP code for login. I need that user who is already loged in was redirected with his parameter TOWN, which has this user in mysql dtb to the subpage town.php. I am sorry I am beginner with PHP :-).
After log in Mrkva will go to A.php and Slana to B.php. Thank you very much.
-table in Mysql dtb
surname pass town
Mrkva 123 A
Slana 456 B
-php
<?php
ob_start();
$dbhost= 'localhost';
$dbuser= 'root';
$dbpassword= '';
$db='doc';
$tbl='tbl';
mysql_connect($dbhost,$dbuser,$dbpassword) or die("cannot connect");
mysql_select_db($db) or die("cannot select DB");
$surname = $_POST['surname'];
$pass = $_POST['pass'];
$sql="SELECT * FROM $tbl WHERE surname='$surname' and pass='$pass' ";
$result=mysql_query($sql);
$count=mysql_num_rows($result) ;
if($count==1){
session_register("surname");
session_register("pass");
header("location:A.php");}
else {
header("location:index.php");
}
ob_end_flush();
?>
|