Jump to content

password verify


searls03

Recommended Posts

ok, so I have this so far and I want it to echo password does not match if password123 does not equal password.  and if it does match the sql query will run.  do i put the else statement after the sql or before it.  could you tell me where to start it........like put a comment that shows where?

 

 <?php
// Process the form if it is submitted
$password1 = $_POST['password'];
$password123 = md5($password1);
if ($_POST['passbut']) {
if ($password123 == $password) { 
$password12 = $_POST['password'];





$sql = mysql_query("UPDATE sessions SET password='$password12' WHERE id='$userid1'")or die(mysql_error());
$message ='Your Account info has been saved';
echo "<font color = 'red'>";
echo  $message;
echo "</font>";
}} // close if post
?>

Link to comment
https://forums.phpfreaks.com/topic/242980-password-verify/
Share on other sites

 <?php
// Process the form if it is submitted
$password1 = $_POST['password'];
$password123 = md5($password1);
if (isset($_POST['passbut'])) {
if ($password123 == $password) { //im assuming that $password is coming from your db
$password12 = $_POST['password'];
$sql = mysql_query("UPDATE sessions SET password='$password12' WHERE id='$userid1'")or die(mysql_error());
$message ='Your Account info has been saved';
echo "<font color = 'red'>";
echo  $message;
echo "</font>";
}else{
      //passwords do not match
}
} // close if post
?>

Link to comment
https://forums.phpfreaks.com/topic/242980-password-verify/#findComment-1248002
Share on other sites

other piece that I want to do is also make sure that the new and confirm passwords match.  how do I do that?

 

 <?php
// Process the form if it is submitted
$password1 = $_POST['password'];
$password2 = $_POST['new'];
$password3 = $_POST['password'];

$password123 = md5($password1);
if (isset($_POST['passbut'])) {



if ($password123 == $password) { 
$password12 = $_POST['password'];
$sql = mysql_query("UPDATE sessions SET password='$password12' WHERE id='$userid1'")or die(mysql_error());
$message ='Your Account info has been saved';
echo "<font color = 'red'>";
echo  $message;
echo "</font>";
}else{
echo '<font color="red">';
      echo "passwords do not match";
  echo '</font>';
}
} // close if post
?> <hr />
              <font size="2px" color="#666666">Your Password</font><br />
              <br />
              <br />
              <br />
              <br />
              </div>
              <div class="CollapsiblePanelContent"><form action="settings.php" method="post"><table width="371" border="0" cellspacing="2" cellpadding="0">
          <tr>
            <td width="109" height="29" scope="col">Old Password:</td>
            <td width="242" scope="col"><label for="password"></label>
              <div align="left">
                <input name="password" type="text" id="password" />
              </div></td>
          </tr>
          <tr>
            <td>New Password:</td>
            <td><label for="new"></label>
              <div align="left">
                <input type="text" name="new" id="new" />
              </div>
              <label for="security"></label></td>
          </tr>
          <tr>
            <td>Confirm Password:</td>
            <td><label for="confirm"></label>
              <div align="left">
                <input type="text" name="confirm" id="confirm" />
              </div>
              <label for="answer"></label></td>
          </tr></table><input name="passbut" type="submit" class="fullname" value="Save Password" id="passbut"/>
          <br />
          <br />
              </form>

Link to comment
https://forums.phpfreaks.com/topic/242980-password-verify/#findComment-1248091
Share on other sites

Your code has a logical problem. Why would you assign the same value to both $password1 and $password3? If anything, shouldn't you be assigning $_POST['confirm'] to one of those, after comparing the values of $_POST['new'] and $_POST['confirm']?

Link to comment
https://forums.phpfreaks.com/topic/242980-password-verify/#findComment-1248823
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.