php - Can not login in my site with mysql_real_escape_string -
I need some help here I have coded some kind of site with "login" system and to prevent SQL injection I am trying. Everything works perfect without passing that. When I add mysql_real_escape_string (), I can not log on to my site more annoying now.
I have no idea what should be wrong, they tried to mislead the problem but got nothing. That's why I've got a form that sends about $ _POST ['user'] and $ _POST ['pass'] to the user in check.php In Check.php I got the code to find out that the user and the user have the equivalent and passes in MySQL db.
& lt ;? Includes php ('mysql.php'); // mysql connection is included if (isset ($ _ POST ['user']) and isset ($ _ POST ['pass'])) {$ user = mysql_real_escape_string ($ _ POST ['user']); $ Pass = mysql_real_escape_string ($ _ POST ['pass']); $ Line = mysql_fetch_row (mysql_query ("Select user from user name = '$ user'")); If ($ user == $ line [1]) and ($ pass == $ line [2])) {setcookie ("user", $ user, time (+3600, "/"); Header ('location: secret.php'); } And {header ('location: index.php'); }; }; The username and password contain only letters and numbers, and I know that I am typing my username and password.
If the user name and password are only alpha-numeric characters, try using it so that You can confirm only $ users and $ pass only alpha-numeric characters. If they are (if they are back), then you do not need to synthesize them.
By the way, you now have mysqli_real_escape_string You can use mysqli_real_escape_string instead!
I hope this is your chance
Take a look at this similar question that has been solved:
Edit: Also, the comment of Fred-e-has caused you to debug your code. Good way is provided.
Comments
Post a Comment