File: /home/awaldron/www/archive/ressyn/password-change.php
<?php
$u->force_login();
if (isset($_POST[changepw])) {
$success = FALSE;
// Setup form validation requirements
$valid[0] = array('oldpw', 'Current Password', 'none', TRUE);
$valid[1] = array(md5($_POST[oldpw]), $db->quickSQL("SELECT user_pass FROM user WHERE uid=".$_SESSION[auth_uid]), 'equal', 'The \'Current Password\' entered is incorrect.');
$valid[2] = array('newpw1', 'New Password', 'none', TRUE);
$valid[3] = array('newpw2', 'Re-Type New Password', 'none', TRUE);
$valid[4] = array($_POST[newpw1], $_POST[newpw2], 'equal', 'The new passwords entered do not match.');
// Run Validation Function
$errors = form_validate($_POST, $valid, '500px');
// If no errors, process form
if (!$errors) {
$db->quickUPDATE("UPDATE user SET user_pass='".md5($_POST[newpw1])."', user_pwchange=0 WHERE uid=".$_SESSION[auth_uid]);
$success = TRUE;
$_POST = array();
}
}
$page_title = "Change Your Password";
$no_robots = TRUE;
include("_header.php");
echo '<div class="sp-content">'.EOL;
echo "<br/>";
if ($success) {
echo '<div class="success" style="width:500px;margin:0 auto;">Password changed successfully.<ul><li> Your password change was successful.</li><li> You may now use your new password.</li></ul><p class="center"><a href="/account">Return to My Account</a></p></div><br/><br/><br/><br/><br/>'."\n";
} else if ($errors) {
echo $errors.'<br/>';
}
if (!$success) {
//echo '<p class="center"><b>Use this form to change your password:</b></p>'.EOL;
echo '<form name="changepw" action="'.self().'" method="post">'.EOL;
echo '<fieldset title="Password Change" id="password-change"><legend> Change Your Password </legend>'.EOL;
echo '<div class="form-row">';
echo '<label for="oldpw">Current Password:</label> ';
echo '<input type="password" name="oldpw" style="width:150px" maxlength="32" class="login" />';
echo '</div>'.EOL;
echo '<div class="form-row">';
echo '<label for="newpw1">New Password:</label> ';
echo '<input type="password" name="newpw1" style="width:150px" maxlength="32" class="login" />';
echo '</div>'.EOL;
echo '<div class="form-row">';
echo '<label for="newpw2">Re-type New Password:</label> ';
echo '<input type="password" name="newpw2" style="width:150px" maxlength="32" class="login" />';
echo '</div>'.EOL;
echo '<div class="form-row2">';
echo '<input type="submit" name="changepw" value="Change Password" class="submit" /> ';
echo '<input type="button" onclick="window.location.href=\'/account\';" value="Cancel" class="submit" />';
echo '</div>'.EOL;
echo '</fieldset>'.EOL;
echo '</form>'.EOL;
}
echo '</div>'.EOL;
include("_footer.php");
?>