<?php
if( !isset($_SESSION) ) { session_start(); }
$database_db="child";
$user_db="root";
$password_db="admin";
$host_db="localhost";
$link=mysql_connect($host_db,$user_db,$password_db) or die ("couldnot connect: ".mysql_error());
mysql_select_db($database_db, $link) or exit('Error Selecting database: '.mysql_error()); ;
$userid=$_POST["userid"];
$password=$_POST["password"];
$type=$_POST["type"];
$errormessage = "";
$sql="SELECT * FROM login where username='$userid' and password='$password' and type='$type'";
$result = mysql_query($sql, $link) or exit('$sql failed: '.mysql_error());
$num_rows = mysql_num_rows($result);
if($num_rows==0){
header("Location: error.php");
} elseif ($num_rows==1) {
if ($type == 1){
header("Location: testadmin.php");
} elseif($type == 2){
header("Location: testuser.php");
}
else
exit;
}
?>
in my phpmyadmin database named "child"
i've placed a table named "login" with three fields namely usename password and type
i need to do a log-in page wherein it can redirect the user depending on his type...
type 1 is an admin and type 2 is a user...
i've been trying to work around it for days..
please help guys this is my first time posting.. thanks to those who will reply


