any help will be much appreciated!!
basically i have a login script, that i want to check mutliple tables and i am stuggling to get it to work!
its for a college project, and basically theres 4 different types of accounts, with different fields in each.
when someone enters an email address and password, i want the script to check each of the 4 tables for what was entered, and then forward them somewhere depending on which table it was found in, or if it wasnt found in any then to another page
Code: Select all
<?php
session_start();
$_SESSION['loggedin'] = false;
include("functions.php");
extract($_POST);
$query = "SELECT * From table1 WHERE email='$email' and password='$password';";
$result = doQuery($query);
if($result==false) {
$query = "SELECT * From table2 WHERE email='$email' and password='$password';";
$result = doQuery($query);
if($result==false) {
$query = "SELECT * From table3 WHERE email='$email' and password='$password';";
$result = doQuery($query);
if($result==false) {
$query = "SELECT * From table4 WHERE email='$email' and password='$password';";
$result = doQuery($query);
if($result==false) {
} else {
if(mysql_num_rows($result)) {
$row = mysql_fetch_assoc($result);
$_SESSION['loggedin'] = true;
$_SESSION['id'] = $_POST['id'];
header("Location:1");
} else {
header("Location:wrong.php");
}
}
} else {
if(mysql_num_rows($result)) {
$row = mysql_fetch_assoc($result);
$_SESSION['loggedin'] = true;
$_SESSION['id'] = $_POST['id'];
header("Location:2");
} else {
header("Location:wrong.php");
}
}
} else {
if(mysql_num_rows($result)) {
$row = mysql_fetch_assoc($result);
$_SESSION['loggedin'] = true;
$_SESSION['id'] = $_POST['id'];
header("Location:3");
} else {
header("Location:wrong.php");
}
}
} else {
if(mysql_num_rows($result)) {
$row = mysql_fetch_assoc($result);
$_SESSION['loggedin'] = true;
$_SESSION['id'] = $_POST['id'];
header("Location:4");
} else {
header("Location:wrong.php");
}
}
?>