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
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']);
              }
        }
?>

Link to comment
Share on other sites

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 } ?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.