Searching two tables for login data
Posted: Thu Apr 20, 2006 10:37 am
feyd | Please use
feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
I am using this section of code to search two tables and depending on the table sent the user to a different webpage...but it isnt quite workin properly, it will send me to the correct page (Registration.php) if i enter a username and password from the piclogin table, also it will ask me to re-enter a username and password if i type in something which isnt in both tables however it is not finding the username and password entered in the newlogin table and as a result it is askin me to re-enter a username and password..... any help greatly appreciated
StephenCode: Select all
<?
if ($case == 1)
{
$tbl = 'newlogin';
$dest = 'home.htm';
}
else
{
$tbl = 'piclogin';
$dest = 'Registration.php';
}
$qry = "SELECT * FROM `{$tbl}` WHERE `username`='$username' AND `password` = '$password'";
$result = mysql_query($qry);
if($rec=mysql_fetch_array($result))
{
if(($rec['username']==$username)&&($rec['password']==$password))
{
echo "<p class=data> <center>Successfully Logged in<br>
<br>
<a href='Log out.php'> Log OUT </a><br>
<br>
<a href=home.htm>Click here if your browser is not redirecting automatically or you don't want to wait.</a>
<br></center>";
}
print "<script>";
print " self.location='{$dest}';"; // re-direct
print "</script>";
}
echo "<font face='Verdana' size='2' color=red><center>Wrong Login. Please Enter your Username and Password and Try Again </center><br>
<p> </p><center><input type='button' value='Retry' onClick='history.go(-1)'></center>";
?>feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]