Jump to content

[SOLVED] pword change help


Clinton

Recommended Posts

If I type in an incorrect password and then make it so the npword and vnpword do not match I would assume it would kick me back with the error that "Hey CHucklehead... the passwords don't match!" Instead it jumps straight to the "An error has encountered" section. I've jacked around with this for a while. What curly bracket is misplaced because I cannot figure it out *Bangs head against desk*

 

<?php
session_start();
include 'connect/project.htm';

if(($_SESSION['logged_in'] == 1) && ($_SESSION['access_type'] == e))
{
$uid = mysql_real_escape_string($_SESSION['user_id']);
$query = mysql_query("SELECT * FROM users WHERE username = '$uid'");
$row = mysql_fetch_assoc($query);
extract($row);



if (isset($_POST['submit'])) {
        $errors = array();

///Checks Password///

      if ((!empty($_POST['opword'])) && (!empty($_POST['npword'])) && (!empty($_POST['vnpword'])))				{
              if ($_POST['npword'] != $_POST['vnpword']) {
                  $$_SESSION['resultp'] = '<font color="red">The 2 passwords you have entered do not match.</font>'; header("Location: myinfo.php");
              } elseif ($password != md5($_POST['opword'])) {
                  $_SESSION['resultp'] = '<font color="red">Your old password was entered incorrectly. Try again.</font>'; header("Location: myinfo.php");
              } else {
                  $password = md5($_POST['npword']);
              }

          
///Confirms and Inserts///
      if (empty($_SESSION['resultp'])) {

                 $query = "UPDATE users SET password = '$password' WHERE username = '$uid'";

			 $result = mysql_query($query);
			                        }

			 if (mysql_affected_rows() == 1) {

$_SESSION['resultp'] = '<font color=lightgreen> Your password has been successfully changed.</font>'; header("Location: myinfo.php");

} else { $_SESSION['resultp'] = '<font color=red> An error was encountered. Please try again.</font>'; header("Location: myinfo.php"); }

}

else { $_SESSION['resultp'] = '<font color=red> Filling out at least one field would get you a little further then filling out none and hitting submit. :-)</font>'; header("Location: myinfo.php"); }


  }else { $_SESSION['resultp'] = '<font color=red>Ummmm... it seems like you are trying something un-kosher. I am watching. </font>'; header("Location: myinfo.php"); }     } else { ?>

<html>
<head>
<title>intelliPursuit: 10-31</title>
<meta http-equiv="refresh" content="2;url=index.php" />
</head>
<body>
We have a 10-31. Login or face prosecution!
</body>
</html>
<?php } ?>

Link to comment
https://forums.phpfreaks.com/topic/140080-solved-pword-change-help/
Share on other sites

It look like your missing } on the check password

 

<?php
   if ((!empty($_POST['opword'])) && (!empty($_POST['npword'])) && (!empty($_POST['vnpword'])))            {
              if ($_POST['npword'] != $_POST['vnpword']) {
                  $$_SESSION['resultp'] = '<font color="red">The 2 passwords you have entered do not match.</font>'; header("Location: myinfo.php");
              } elseif ($password != md5($_POST['opword'])) {
                  $_SESSION['resultp'] = '<font color="red">Your old password was entered incorrectly. Try again.</font>'; header("Location: myinfo.php");
              } else {
                  $password = md5($_POST['npword']);
              }
        }
?>

I figured it out... that second big IF statement was jacking me up. I didn't need it because if any of the other errors would have occurred it would have followed the header instead of completing the rest of the script.

 

 

<?php
session_start();
include 'connect/project.htm';

if(($_SESSION['logged_in'] == 1) && ($_SESSION['access_type'] == e))
{
$uid = mysql_real_escape_string($_SESSION['user_id']);
$query = mysql_query("SELECT * FROM users WHERE username = '$uid'");
$row = mysql_fetch_assoc($query);
extract($row);



if (isset($_POST['submit'])) {
        $errors = array();

///Checks Password///

      if ((!empty($_POST['opword'])) && (!empty($_POST['npword'])) && (!empty($_POST['vnpword'])))				{
              if ($_POST['npword'] != $_POST['vnpword']) {
                  $_SESSION['resultp'] = '<font color=red>The 2 passwords you have entered do not match.</font>'; header("Location: myinfo.php");
              } elseif ($password != md5($_POST['opword'])) {
                  $_SESSION['resultp'] = '<font color=red>Your old password was entered incorrectly. Try again.</font>'; header("Location: myinfo.php");
              } else {
                 $password = md5($_POST['npword']);
              
                 $query = "UPDATE users SET password = '$password' WHERE username = '$uid'";

			 $result = mysql_query($query);

$_SESSION['resultp'] = '<font color=lightgreen> Your password has been successfully changed.</font>'; header("Location: myinfo.php");

} 

} else { $_SESSION['resultp'] = '<font color=red> Please fill out all three fields.</font>'; header("Location: myinfo.php"); }


} else { $_SESSION['resultp'] = '<font color=red>Ummmm... it seems like you are trying something un-kosher. I am watching. </font>'; header("Location: myinfo.php"); }


} else { ?>

<html>
<head>
<title>intelliPursuit: 10-31</title>
<meta http-equiv="refresh" content="2;url=index.php" />
</head>
<body>
We have a 10-31. Login or face prosecution!
</body>
</html>
<?php } ?>

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.