Originally Posted by
jmarcv
select id from check_db1.table
UNION
select id from db2.table2
I need to check if the email exists in either db tables and if it does in either allow login.
Both tables have different ID's assigned to the user so I tried email and * with a WHERE email = $email and couldn't get any combination to work.
If I use a separate member db for login then once they are logged in I am successfully querying each db.table and displaying information by where the user is located in the databases.
This is what I have after they login using a members db (which I would like to eliminate):
PHP Code:
<?php
//Include database connection details
require_once('config.php');
//Connect to mysql server
$link2 = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD);
if(!$link2) {
die('Failed to connect to server: ' . mysql_error());
}
//Create query
$qry2="SELECT * FROM db_store.login WHERE Email='$email' AND PW='$password'";
$result2=mysql_query($qry2);
//Check whether the query was successful or not
if($result2) {
if(mysql_num_rows($result2) == 1) {
//Client in store db
echo "client is in store db";
}else {
//Client not in store db
echo "client is NOT in store db";
}
}
?>
<?php
//Create query
$qry3="SELECT * FROM db_host.users WHERE email='$email'";
$result3=mysql_query($qry3);
while ($row = mysql_fetch_assoc($result3)) {
$id = $row['id'];
$username = $row['email'];
echo "<br />" . $id . $username . $password;
echo "<br />";
}
//Check whether the query was successful or not
if($result3) {
if(mysql_num_rows($result3) == 1) {
//Client in host db
echo "client is in host db";
}else {
//Client not in host db
echo "client is NOT in host db";
}
}
?>