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'm making php file called changepassword.php , sole purpose of file allow user change password. however, when go through form change password box fields clear , receive echo warning echo "a password box left empty!". not want seem update user's password , have no clue do. new language don't expect much. appreciate constructive input me code php better.

<?php session_start();  #error_reporting(e_all); ini_set('display_errors', 1); require_once('connect.php'); require_once "lib.php"; require_once "utils.php";  if(isset($_post['submit']) && $_session['active']===true) {     if(!empty($_post['oldpassword'])&&         !empty($_post['newpassword'])&&         !empty($_post['newpassword1']))     {         $oldpassword = mysqli_real_escape_string($link,htmlentities($_post['oldpassword']));         $newpassword = mysqli_real_escape_string($link,htmlentities($_post['newpassword']));         $newpassword1 = mysqli_real_escape_string($link,htmlentities($_post['newpassword1']));          $emailadress = $_session['emailadress'];         $sql = "select * users emailaddress='$emailaddress'";          if($result = mysqli_query($link, $sql))         {             while($row = mysqli_fetch_array($result, mysqli_assoc))             {                 $temp1=$row['password'];                 if($row['password'] != $oldpassword)                 {                     echo "<div id='change_error1'>* not match previous password!<br></div>";                 }             }              if($newpassword != $newpassword1)             {                 echo "<div id='change_error2'>* passwords not match!</div>";             }              if($temp1 == $oldpassword && $newpassword == $newpassword1)             {                 $sql = "update users set password='$newpassword' emailaddress='$emailaddress'";                 if($result = mysqli_query($link, $sql))                 {                     header("location: profile.php");                     echo "<strong>youre password has been updated!</strong>";                 }             }         }     }     else     {         echo "<div id='change_error3'>a password box left empty!</div>";     } } ?> <html>    <head>       <title>change password</title>    </head>    <br></br>    <br></br>    <body class="body">       <div id="wrapper">          <div id="header">             <br>             <h1> php learning course </h1>             <br>             <?php require_once "left.php" ?>          </div>          <div id="change">             <div id="change_name">                <h3> change password</h3>             </div>             <p>             <div id='change_form'>                <form action='changepass.php' method='post'>                   old password:<br> <input name='oldpassword' type='password'/></br>                   <br>                   new password:<br> <input name='newpassword' type='password'/></br>                   <br>                   confirm password:<br> <input name='newpass1' type='password'/></br>                   <br>                   <input name='submit' type='submit' value='change password' />                </form>                </p>             </div>          </div>          <!-- end main div -->       </div>       <!-- end wrapper div -->    </body> </html> 

 !empty($_post['newpassword1'])) 

index should be, newpass1

i.e. !empty($_post['newpass1']))

because in form, have put,

 confirm password:<br> <input name='newpass1' type='password'/></br> 

stick 1 convention avoid these errors.


Comments

Popular posts from this blog

node.js - Mongoose: Cast to ObjectId failed for value on newly created object after setting the value -

[C++][SFML 2.2] Strange Performance Issues - Moving Mouse Lowers CPU Usage -

ios - Possible to get UIButton sizeThatFits to work? -