I'm making a website where and I need a login file to redirect administrators and clients to their respective account.
It is supposed to verify both tables and see if email corresponds to password.
Here's what I already have
<?php
include "data-base.php";
if($_SESSION){
header("location: index.php?site=perfil");
echo "<script>window.location.href = \"index.php?site=login&erro=3\";</script>";
}
$result = mysql_query("select * from admin, clients where email='".$_POST['email']."' and password='".$_POST['password']."'");
if (mysql_num_rows($result)>0)
{
$linha = mysql_fetch_array($result);
$_SESSION['id']=$linha['id'];
if($linha['email'] = "admin") {
header("location: admin.php?id=".$linha['id']."");
} else {
header("location: client.php?id=".$linha['id']."");
}
} else {
echo "<script type=\"text/javascript\">alert(\"Incorrect email or password\"); window.location = 'index.php';</script>";
}
?>