Hi,
$result = mysql_query("SELECT * FROM tablename WHERE
userName='$userName' AND password = '$password'");
if($rec = mysql_fetch_array($result)){
//your code
}
Try like this it may solve. It may solve your problem
Don't try to fetch the result from one single line code.
Warm Regards,
Sanjeev
http://www.sanchanworld.com/
http://webdirectory.sanchanworld.com - Submit your website URL
http://webhosting.sanchanworld.com - Choose your best web hosting plan
-----Original Message-----
From: Chris Carter [mailto:[EMAIL PROTECTED]
Sent: Sunday, September 16, 2007 3:10 PM
To: [email protected]
Subject: [PHP] php Login script issue
Hi,
Its just a login and password validation that I am trying to achieve. If the
username is correct then the person is able to view certain page, if
incorrect then he is directed elsewhere.
<?
$userid=mysql_real_escape_string($userid);
$password=mysql_real_escape_string($password);
if($rec=mysql_fetch_array(mysql_query("SELECT * FROM tablename WHERE
userName='$userName' AND password = '$password'"))){
if(($rec['userName']==$userName)&&($rec['password']==$password)){
include "../include/newsession.php";
echo "<p class=data> <center>Successfully,Logged in<br><br>
logout.php Log OUT <br><br> welcome.php Click here if your browser is not
redirecting automatically or you don't want to wait. <br></center>";
print "<script>";
print " self.location='submit-store-details.php';"; // Comment this
line if you don't want to redirect
print "</script>";
}
}
else {
session_unset();
echo "Wrong Login. Use your correct Userid and Password and Try
<br><center><input type='button' value='Retry'
onClick='history.go(-1)'></center>";
}
?>
I am getting this error when I am using this code:
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result
resource in thispage.php on line 37
Wrong Login. Use your correct Userid and Password and Try
Why does it show up everytime and whats wrong with mysql_fetch_array().
Please advice also if there is some other way available please help me try
that.
Thanks,
Chris
--
View this message in context:
http://www.nabble.com/php-Login-script-issue-tf4450691.html#a12698139
Sent from the PHP - General mailing list archive at Nabble.com.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php