Jump to content

How to get login script to read 2 different tables


zreon

Recommended Posts

Hey all. I'm having a very difficult time figuring out how to get my login script to check 2 different tables for login details.

 

Here is what my working code looks like right now to check 1 table.

 

$db1=mysql_connect("$host", "$username", "$password")or die("cannot connect");
$db_select=mysql_select_db("$db_name", $db1)or die("cannot select DB"); 

$sql="SELECT * FROM $tbl_name WHERE firstname='$myusername' and buyer_email='$mypassword'";
$result=mysql_query($sql, $db1); 

 

I also need it to check this code.

 

$sql="SELECT * FROM $tbl_name2 WHERE login='$myusername' and pass='$mypassword'";
$result=mysql_query($sql, $db1); 

 

Can I get any insight on how to do this? I'm sure it isn't that difficult and I have been searching for 3 days including looking in php books and searching.

Thanks for your quick responses although I'm not exactly sure what they mean. I am really really new with php and am amazed I even have a working login script up.

 

This is how my code looks right now

 

<?php
ob_start();
$host="xxx"; // Host name
$username="xxx"; // Mysql username
$password="xxx"; // Mysql password
$db_name="xxx"; // Database name
$tbl_name="xxx"; // Table name
$tbl_name2="xxx"; // Table name

// Connect to server and select databse.


$db1=mysql_connect("$host", "$username", "$password")or die("cannot connect");
$db_select=mysql_select_db("$db_name", $db1)or die("cannot select DB"); 

$sql="SELECT * FROM $tbl_name WHERE firstname='$myusername' and buyer_email='$mypassword'";
$result=mysql_query($sql, $db1); 

$sql="SELECT * FROM $tbl_name2 WHERE login='$myusername' and pass='$mypassword'";
$result=mysql_query($sql, $db1);

 

As of right now, it will only check the second table for the information.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.