I want to add a condition where if the email is admin@example.com and password is admin, then the admin will be redirected to admin.html, which is different to what a normal user will be redirected to (user.html). P.S. the admin and users are in the same table. Thanks in advance.
<?php
require_once ('../../connect.php');
$user_email = $_POST['user_email'];
$user_password = $_POST['user_password'];
if ($user_email != NULL AND $user_password != NULL)
{
$login = "SELECT * FROM tblusers where user_email = '$user_email' AND user_password = '$user_password' AND user_type=0";
$result = mysqli_query($dbc, $login);
if (mysqli_num_rows($result) >0 )
{
setcookie('user_email', $user_email);
setcookie('user_password', $user_password);
echo '<script type="text/javascript"> window.location ="register.php"; </script>';
}
else
{
echo '<script type="text/javascript"> alert("The email or password you have entered may be incorrect"); window.location ="login.html"; </script>';
}
}
else ($user_email != NULL AND $user_password != NULL)
{
$login = "SELECT * FROM tblusers where user_email = '$user_email' AND user_password = '$user_password' AND user_type=1";
$result = mysqli_query($dbc, $login);
if (mysqli_num_rows($result) >0 )
{
setcookie('user_email', $user_email);
setcookie('user_password', $user_password);
echo '<script type="text/javascript"> window.location ="members.php"; </script>';
}
else
{
echo '<script type="text/javascript"> alert("The email or password you have entered may be incorrect"); window.location ="login.html"; </script>';
}
}
else
{
echo '<script type="text/javascript"> alert("Please enter your email and password in the relative fields"); window.location ="login.html"; </script>';
}
mysqli_close($dbc);
?>