php - Mysqli does not retrieve password from database -
I am starting to learn PHP and using mysqli I am working on a simple password change script. I am using a MySQL tutorial as a reference. Now I have a problem where my code is unable to get the old password from the database, and I have not received any error messages.
if ($ user) {// start password change ($ submit) {$ oldpassword = $ _POST ['oldpassword']; $ Newpassword = $ _POST ['new password']; $ Repeat_newpassword = $ _POST ['repeat_newpassword']; // $ db connect = mysqli_connect ($ mysqli_error (connect) "Could not connect to database!".) Connect ("localhost", "root", "****", "registration") or die Go; $ Queryget = mysqli_query ($ Connect, "Username WHERE Username = '$ user'" "Select password) or die (" query error ". Mysqli_error ($ connect)); $ line = mysqli_fetch_assoc ($ queryget); $ Oldpassworddb = $ line ['password']; // if checking fields are filled in ($ oldpassword & amp; $ newpassword & amp; $ repeat_newpassword) {if ($ oldpassword $ oldpassworddb ==) {If ($ newpassword == $ repeat_newpassword) {$ querychange = mysqli_query ($ connect, "user update password = '$ new password' WHERE user name = '$ user'") or die ("pass Word query error ". Mysqli_error ($ connect)); session_destroy (); die (" & lt; a href = login.php & gt; 'Return to login.' & Lt; / a & gt; ");} and Die ("new passwords are not match!");} And die ("old password is not match!");} And echo "all fields should be filled!";}
when Also I enter in the $ oldpassword
, this "does not match the old password"; even if the old password I enter matches one of the databases. I have also checked the DB password to ensure that there is no free space or this kind of problem arises.
$ oldpassword echo "& lt; br & gt;"; Echo $ oldpassworddb "& lt; br & gt;"; $ Count = mysqli_num_rows ($ queryget); Echo $ count; Die (); I have used it to see if the code will print the value from the DBS password block, but it returns only $ oldpassword
and $ count
Returns '0' This definitely connects to the database and a user is present, so I have to do something related to the query. I appreciate the help, I think that this is a very simple fix due to the slight difference between mysql and mysql, but I'm having a hard time finding a similar problem / solution online. .
Post text "itemprop =" text "> You should not attempt to get the password from the table, but to check that the password is getting, so use of
Select user name where user name = '$ user and password = password (' $ oldpassword ')
Comments
Post a Comment