Hey iam new in php code and i tried to created login which has two type of user(Normaluser and Amdminuser)
but i tried to create query where i want when normal user has loged in, to be able to fetch specified data from database
just normal user so please need your help
Here is my code
<?php
$action=isset($_POST['login']);
if($action == 'login')
{
$Uname = mysql_prep($_POST['Uname']);
$Password = mysql_prep($_POST['Pass']);
$query = mysql_query("SELECT u.userId,u.Uname,u.Passoword,
r.roleId,r.rolename FROM users u, role r,
previlage p WHERE u.Uname='$Uname' AND u.Password='$Password'
AND p.roleId = r.roleId AND u.userId=p.userId")
or die("System fails to look for user data!");
list($userId,$Uname,$Password,$roleId,$rolename)=mysql_fetch_array($query);
if(mysql_num_rows($query) == 0){
echo"<table border='0' width='500' height='50px'align='center' ><tr>
<td align='center' style='background:; color:#F00; fontsize:20px'>
<b> Sorry Password or Username is incorrent or not exist in this system
Please contact our Administration for any <br>Informantion about the system
</br>Email:rashidabeid@yahoo.com</br>Phone +255777415640
</br> Thanks!!
</td></tr></table>";
}
else{
if($rolename == "Administrator")
{
$_SESSION['roleId'] = $roleId;
$_SESSION['rolename'] = $rolename;
$_SESSION['userId'] = $userId;
$_SESSION['Uname'] = $Uname;
$_SESSION['Password'] = $Password;
header('Location:userlogin.php');
exit;
}
if($rolename == "Normaluser"){
$_SESSION['roleId'] = $roleId;
$_SESSION['rolename'] = $rolename;
$_SESSION['userId'] = $userId;
$_SESSION['Uname'] = $Uname;
$_SESSION['Password'] = $Password;
$sql = mysql_query("
select* FROM vaccine
WHERE ='$PassportNo'
and CodeNo='$CodeNo'
");
$result=mysql_query( $sql);
while ($row = mysql_fetch_array($result)) {
echo 'SerialNo: '.$row['SerialNo'];
echo '<br/> Country: '.$row['Country'];
echo '<br/> Station: '.$row['Station'];
echo '<br/> CodeNo: '.$row['CodeNo'];
echo '<br/> Phone: '.$row['PhoneNo'];
echo '<br/><br/>';
}
exit;
}
}
}
?>