- FOLLOWING ARE STEPS TO CREATE LOGIN PAGE THAT ALLOW ACCESS BASED ON ROLES (USER TYPE)
STEP -1 CREATE TABLES(multiple users tables) IN DATABASE .
STEP -2 create login page.
For example
<?php
if(isset($_POST['login']))
{
$log=new Login();
$username=$_POST['uname'];
$password=$_POST['upass'];
$result1=$log->User1($username,$password);
if($result1)
{
echo "WellCome user 1";
}
$result2=$log->User2($username,$password);
if($result2)
{
echo "WelCome user 2";
}
$result3=$log->User3($username,$password);
if($result3)
{
echo "wellcom user 3"
}
if(!$result1)
{
if(!$result2)
{
if(!$result3)
{
echo "<script>alert('Invalid Username / Password,Please try Again..!!');</script>";
}
}
}
}
?>
<form action="" method="post">
username : <input type="text" name="uname">
password : <input type="password" name="pass">
<input type="submit" name="login">
STEP - 3 create function page for 3 users
function User1($username,$password)
{
$sql1="SELECT * FROM admin WHERE Email='$username' AND password='$password'";
$qry1=mysql_query($sql1);
$num=mysql_num_rows($qry1);
if($num > 0)
{
return $qry1;
}
}
function User2($username,$password)
{
$sql2="SELECT * FROM client WHERE Email='$username' AND password='$password'";
$qry2=mysql_query($sql2);
$num2=mysql_num_rows($qry2);
if($num2 > 0)
{
return $qry2;
}
}
function User3($username,$password)
{
$sql3="SELECT * FROM developer WHERE Email='$username' AND password='$password'";
$qry3=mysql_query($sql3);
$num3=mysql_num_rows($qry3);
if($num3 > 0)
{
return $qry3;
}
}
STEP - 4 FINISH
NOTE : PLEASE CREATE SOME OTHER PAGE LIKES THAT IS NOT SHOWN HERE LIKE CONNECTION PAGE [config.php]
not working...Oh My God...please go learn php
ReplyDelete