Sunday, 15 March 2015

mysqli - PHP changing password and it's not working. There is no error with the syntax I believe, but the password won't change -


I am creating a php file named changepassword.php and the sole purpose of the file is to give the user his password. However, when they clean the box field to change their password through the form and I get my echo warning, "A password box was left empty!" It does not want to update the user's password and I have no clue what to do. I am new to this language, so it is not so expected that I would appreciate some creative inputs to help improve code php.

  & lt ;? Php session_start (); #error_reporting (E_ALL); Ini_set ('display_errors', 1); Need_once ('connect.php'); Need_once "lib.php"; Need_once "utils.php"; If (isset ($ _ POST ['submit']) & amp; $ _SESSION ['active'] === true) {If (! ($ _ POST ['OldPassword']) & amp; amp; Free ($ _POST ['NewPassword']) & amp; Lower ($ _ POST ['NewPassword1'])) {$ OldPassword = mysqli_real_escape_string ($ link, HTMLentities ($ _ POST ['OldPassword'])); $ Nupsword = mysqli_real_escape_string ($ links, htmlentities ($ _ POST ['newpassword'])); $ NewPassword1 = mysqli_real_escape_string ($ link, HTMLentities ($ _ POST ['NewPassword1'])); $ Email ad = $ _SESSION ['EmailAdress']; $ Sql ​​= "Select * From user where email address = '$ email address''; if ($ result = mysqli_query ($ link, $ sql)) {while ($ row = mysqli_fetch_array ($ result, MYSQLI_ASSOC)) {$ Temp1 = $ row ['password']; if ($ line ['password']! = $ Old password) {resonant "
& Lt; / Div> ";}} If ($ Newpass! = $ Newpassword 1) {resonant" and IDE = 'change_arb2' & gt; * You do not forget the password! & Lt; / Div> ";} if ($ temp1 == $ old password & $ NewPassword == $ nypwar1) {$ sql =" update password to user "'$ newpassword' 'email address =' ​​$ email Address' ''; If ($ result = mysqli_query ($ link, $ sql)) {header ("location: profile.php"); Echo "& lt; strong & gt; Eure password has been updated! & Lt; / strong & gt;"; }}}} And {echo "
;); }}? & Gt; & Lt; Html & gt; & Lt; Top & gt; & Lt; Title & gt; Change Password & lt; / Title & gt; & Lt; / Head & gt; & Lt; Br> & Lt; / Br & gt; & Lt; Br> & Lt; / Br & gt; & Lt; Body class = "body" & gt; & Lt; Div id = "wrapper" & gt; & Lt; Div id = "header" & gt; & Lt; Br> & Lt; H1 & gt; PHP Learning Course & lt; / H1> & Lt; Br> & Lt ;? Php require_once "left.php"? & Gt; & Lt; / Div & gt; & Lt; Div id = "change" & gt; & Lt; Div id = "change_name" & gt; & Lt; H3 & gt; Change Password & lt; / H3 & gt; & Lt; / Div & gt; & Lt; P & gt; & Lt; Div id = 'change_form' & gt; & Lt; Form action = 'changepass.php' method = 'post' & gt; Old password: & lt; Br> & Lt; Input name = 'old password' type = 'password' / & gt; & Lt; / Br & gt; & Lt; Br> New Password: & lt; Br> & Lt; Input name = 'newpassword' type = 'password' / & gt; & Lt; / Br & gt; & Lt; Br> Confirm Password: & lt; Br> & Lt; Input name = 'newpass1' type = 'password' / & gt; & Lt; / Br & gt; & Lt; Br> & Lt; Input name = 'submit' type = 'submit' value = 'change password' / & gt; & Lt; / Form & gt; & Lt; / P & gt; & Lt; / Div & gt; & Lt; / Div & gt; & Lt ;! - End main div - & gt; & Lt; / Div & gt; & Lt ;! - End Cover Div - & gt; & Lt; / Body & gt; & Lt; / Html & gt;

 ! Blank ($ _ POST ['NewPassword1']))  

should be index, newpass1

i.e. ! Empty ($ _ POST ['newpass1']))

Because in the form, you have entered,

  Confirm the password: & lt; Br> & Lt; Input name = 'newpass1' type = 'password' / & gt; & Lt; / Br & gt;  

Stay with a conference to avoid these errors.


No comments:

Post a Comment