ArcadEd
03-21-2006, 07:50 PM
I'm fairly new to PHP and I've been looking through some example code and I am having a hard time figuring out why this isn't working.
if($rec=mysql_fetch_array(mysql_query("SELECT * FROM devs WHERE uname='$uname' AND password = '$password'"))){
if(($rec['uname']==$uname)&&($rec['password']==$password)){
echo "<p class=data> <center>Successfully,Logged in<br><br><a href='logout.php'> Log OUT </a><br><br><a href=welcome.php>Click here if your browser is not redirecting automatically or you don't want to wait.</a><br></center>";
print "<script>";
print " self.location='welcome.php';"; // Comment this line if you don't want to redirect
print "</script>";
}
}
else {
session_unset();
echo "<font face='Verdana' size='2' color=red>Wrong Login. Use your correct UserName and Password and Try <br><center><input type='button' value='Retry' onClick='history.go(-1)'></center>";
Now, my login page works fine. If I use a good Uname and Password I just get a blank screen, like the If statement is true, but none of the echo's or redirects happen.
If I put in a bad name and password, the else statement works perfect.
I can't figure out what I am missing. Thanks.
if($rec=mysql_fetch_array(mysql_query("SELECT * FROM devs WHERE uname='$uname' AND password = '$password'"))){
if(($rec['uname']==$uname)&&($rec['password']==$password)){
echo "<p class=data> <center>Successfully,Logged in<br><br><a href='logout.php'> Log OUT </a><br><br><a href=welcome.php>Click here if your browser is not redirecting automatically or you don't want to wait.</a><br></center>";
print "<script>";
print " self.location='welcome.php';"; // Comment this line if you don't want to redirect
print "</script>";
}
}
else {
session_unset();
echo "<font face='Verdana' size='2' color=red>Wrong Login. Use your correct UserName and Password and Try <br><center><input type='button' value='Retry' onClick='history.go(-1)'></center>";
Now, my login page works fine. If I use a good Uname and Password I just get a blank screen, like the If statement is true, but none of the echo's or redirects happen.
If I put in a bad name and password, the else statement works perfect.
I can't figure out what I am missing. Thanks.