centenial
06-20-2006, 10:46 PM
Hi,
I have two tables in my MySQL database:
1. companies
2. employees
Each table has some different fields, but they each have the three same login fields:
1. email
2. password
3. company_admin (Has a value of either 1 or 0)
I want to be able to use one login script for both types of users, and assign them a session value of 1 or 0 depending on whether they have "Company_Admin" powers.
Here's what I have so far, but it keeps giving me a "Column 'email' in where clause is ambiguous" error - Can someone please help?
include 'db.php';
$check = "SELECT * FROM companies, employees WHERE email = '$_POST[email]' AND password = '$_POST[password]'";
$check_result = mysql_query($check,$conn) or die(mysql_error());
if (mysql_num_rows($check_result) > 0) {
while ($res = mysql_fetch_array($check_result)) {
$_SESSION[login_id] = $res['id'];
$_SESSION[company_admin] = $res['company_admin'];
}
header("Location: index.php");
exit;
} else {
$display_block = "We're sorry, but your login information appears to be incorrect. Would you like to <a href=\"$_SERVER[PHP_SELF]\">try again</a>?";
}
Thanks!
I have two tables in my MySQL database:
1. companies
2. employees
Each table has some different fields, but they each have the three same login fields:
1. email
2. password
3. company_admin (Has a value of either 1 or 0)
I want to be able to use one login script for both types of users, and assign them a session value of 1 or 0 depending on whether they have "Company_Admin" powers.
Here's what I have so far, but it keeps giving me a "Column 'email' in where clause is ambiguous" error - Can someone please help?
include 'db.php';
$check = "SELECT * FROM companies, employees WHERE email = '$_POST[email]' AND password = '$_POST[password]'";
$check_result = mysql_query($check,$conn) or die(mysql_error());
if (mysql_num_rows($check_result) > 0) {
while ($res = mysql_fetch_array($check_result)) {
$_SESSION[login_id] = $res['id'];
$_SESSION[company_admin] = $res['company_admin'];
}
header("Location: index.php");
exit;
} else {
$display_block = "We're sorry, but your login information appears to be incorrect. Would you like to <a href=\"$_SERVER[PHP_SELF]\">try again</a>?";
}
Thanks!