post form vars to php without redirect?
Posted: Sun May 09, 2010 9:51 am
Hi,
I am making a "password reset" page and want the submitted data to run through php but don't want the page to redirect to the php page.
Here's the code so far. My script will check that the old password exists in the database and the two new ones match. Then it will replace the one in the database with the new one (md5 encrypted). I have all the code worked out as far as the actual processing but don't know any other way to get the form vars to the php without post. I don't want the browser to redirect though. I just want it to display the success or error message under the "change password" and "cancel" buttons.
I can't have the changeProfile.php redirect back to this page because it's a redirect loop.
I am making a "password reset" page and want the submitted data to run through php but don't want the page to redirect to the php page.
Here's the code so far. My script will check that the old password exists in the database and the two new ones match. Then it will replace the one in the database with the new one (md5 encrypted). I have all the code worked out as far as the actual processing but don't know any other way to get the form vars to the php without post. I don't want the browser to redirect though. I just want it to display the success or error message under the "change password" and "cancel" buttons.
I can't have the changeProfile.php redirect back to this page because it's a redirect loop.
Code: Select all
<?php
include '../includes/changeProfile.php';
session_start();
if ($_SESSION['userName']!= 'valid' or $_SESSION['password'] != 'valid'){
//redirect
header("location: ../login.html");
}
$user = $HTTP_SESSION_VARS ["name"];
?>
<html>
<head>
<link rel="stylesheet" type="text/css" href="profile.css" media="screen" />
<title>User Profile</title></head>
<body>
<!--Wrap Start-->
<div id="wrap">
<div class="header"></div>
<!--Content Start-->
<div id="content">
<form action="../includes/changeProfile.php" method="POST">
User Name:<input type="text" name="un" size="25" maxlength="25" value="<?php echo $user;?>"></input>
<br />
<br />
Enter Current Password:<input type="password" name="pw" size="25" maxlength="25"></input>
<br />
Enter New Password:<input type="password" name="npw" size="25" maxlength="25"></input>
<br />
Confirm New Password:<input type="password" name="cpw" size="25" maxlength="25"></input>
<br />
<input type="submit" name="submit" value="Change Password"></input>
<input type="reset" name="reset" value="Cancel"></input>
</form>
<?php
if($changeSuccess == 'true'){
echo '<h3>Password Succesfully Changed!!</h3>';
}
else {echo 'There was a problem and your password did not change. Please try again';}
?>
</div>
<!--Content End-->
</div>
<!--Wrap End-->
</body>
</html>