I am having a log in page(login-form.php) and i need to use the same page to fetch user details from two different tables namely tb_premium_user and tb_business_user, how can i implement this effectively, can somebody help me in this.I am really looking forward for some reliable suggestions.
If you have the users’ information in both tables, then you would just use two queries.
[php]$prem_user_query = mysql_query(“SELECT * FROM tb_premium_user
etc. etc.”);
$bus_user_query = mysql_query(“SELECT * FROM tb_business_user
etc. etc.”);
if(mysql_num_rows($prem_user_query) == 1 && mysql_num_rows($bus_user_query) == 1) {
$prem_user_record = mysql_fetch_array($prem_user_query);
$bus_user_record = mysql_fetch_array($bus_user_query);
// More processing here
} else {
echo ‘Invalid username / password!’;
}[/php]
Alternatively, if the user will exist in one of the tables:
[php]$prem_user_query = mysql_query(“SELECT * FROM tb_premium_user
etc. etc.”);
if(mysql_num_rows($prem_user_query) == 1) {
$prem_user_record = mysql_fetch_array($prem_user_query);
// More processing here
} else {
$bis_user_query = mysql_query(“SELECT * FROM tb_business_user
etc. etc.”);
if(mysql_num_rows($bis_user_query) == 1) {
$bis_user_record = mysql_fetch_array($bis_user_query);
// More processing
} else {
echo 'Invalid username / password!';
}
}[/php]