Afficher un message
Vieux 16/09/2007, 14h48   #4
Bastien Koert
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut RE: [PHP] php Login script issue


argh! hotmail sucks

I don't see in the script where you are using $_POST / $_GET / $_REQUEST toaccess tha data from the form. Its likely that the example you are following is old and uses 'register_globals'. Since register_globals is a huge security hole and is not active in any new installations of PHP you need to change your script to use the above methods to get the form data. The error you are getting is due to the fact that you are not passing in the values tothe sql and not getting a valid result

Note that the below example fixes your issue but DOES NOT do any validation, which you really should do before passing your data to the sql...




$userid=mysql_real_escape_string($_POST['userid']);
$password=mysql_real_escape_string($_POST['password']);

if($rec=mysql_fetch_array(mysql_query("SELECT * FROM tablename WHERE> userName='$userName' AND password = '$password'"))){

if(($rec['userName']==$userName)&&($rec['password']==$password))


bastien



----------------------------------------> Date: Sun, 16 Sep 2007 02:39:57 -0700> From: chandan9sharma@yahoo.com> To: php-general@lists.php.net> 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 " Successfully,Logged in> logout.php Log OUT welcome.php Click here if your browser is not> redirecting automatically or you don't want to wait. ";> print "";>> }> }> else{>> session_unset();> echo "Wrong Login. Use your correct Userid and Password and Try> onClick='history.go(-1)'>";>> }> ?>>> 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 upeverytime and whats wrong with mysql_fetch_array().>> Please advice also if there is some other way available please 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>

__________________________________________________ _______________
Connect to the next generation of MSN Messenger
http://imagine-msn.com/messenger/launch80/default.aspx?locale=en-us&source=wlmailtagline
  Réponse avec citation
 
Page generated in 0,06364 seconds with 9 queries