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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.