Hi,
I need to authenticate 2 kinds of users (journalists and customers)and redirect them to different pages.
My problem starts when I want to redirect them based on WHO they are. Additionally I have 3 variables to be checked in the DB - $user (journalist or customer), $pass (their password) and $login (login name). See the code:
if ($user = 'journalist') {
$sql = "SELECT pass, user, login FROM members WHERE pass='$pass' and user='$user' and login='$login'";
$result = mysql_query($sql,$connection) or die ('no connection with the DB");
$num = mysql_numrows($result);
if ($num == 1) {
header('Location: journalists.php');
}
else {
header('Location: register_journalist.php');
}
else if ($user = 'customer') {
$sql = "SELECT pass, user, login FROM members WHERE pass='$pass' and user='$user' and login='$login'";
$result = mysql_query($sql,$connection) or die ('no connection with the DB");
$num = mysql_numrows($result);
if ($num == 1) {
header('Location: customers.php');
}
else {
header('Location: register_customer.php');
}
mysql_close($connection);
It looks that the script goes up to the end of the first IF statement and either redirects to register_journalist.php (even though the user is a customer) or hangs up!?
Any ideas what may be missing?
Witold