mysql - Login php script -
I have a login script here. I removed it from the database user name / password to post on the stack. My problem is that it tells me every time that I write a username and a password (even if they are correct) that the password and username are invalid. I obviously select from * ...... and then a variable $ rows affected rows, but its value is 0 and I am not able to log in.
& lt; H1 & gt; Login & lt; / H1> & Lt; Form action = "" method = "post" & gt; Username: & lt; Input type = "text" name = "username" placeholder = "user name" value = "" /> & Lt; Br / & gt; Password: & lt; Input type = "password" name = "password" placeholder = "*******" value = "" /> & Lt; Br / & gt; & Lt; Input type = "submit" name = "submit" value = "sign in" /> & Lt; Br / & gt; & Lt; / Form & gt; & Lt ;? Php $ error = ''; Empty ($ _ POST ['password'])) {$ error = "Username or password is empty" (isset ($ _ POST ['submit']) {if (empty ($ _ POST ['username' ]); Echo $ error;} and {$ username = $ _ POST ['username']; $ password = $ _ post ['password']; $ Connection = mysql_connect ("mysql.hostinger.ro", "_patr0 $ Username = stripslashes ($ user name); $ password = strip slash ($ password); $ Username = mysql_real_escape_string ($ user name); $ password = mysql_real_escape_string ($ password); $ db = mysql_select_db (" _ppl ", $ connection); $ Query = mysql_query (" Select from people * where pw = '$ password' and username = '$ username' ", $ Connections = mysql_num_rows ($ query); if ($ rows == 1) {/ * $ _ session ['login_user'] = $ user name; * / // session start 'you are logged in' ;} And {$ error = "username or password is invalid"} echo $ error; mysql_close ($ connection); // connection off}} ?? Yes, I'm sure David uses AES_ encrypt ('A' Has stored the password using I & rsquo;
This may be your problem when you run your own mysql query So you are trying to match plain text passwords from user input, but you need to encrypt the passwords in your SQL query as encrypted strings they store.
Comments
Post a Comment