I was following this tutorial by Temor
viewtopic.php?f=25&t=1640
And I tried to write up the change password page and update function.
This is what I have got so far.
The password reset front end page.
[syntax=php]<?php
$path = $_SERVER['DOCUMENT_ROOT'];
$path .= "/members/includes/header.php";
include_once($path);
?>
<html>
<body>
<form action="for.php" method="post" class="registration_form">
<fieldset>
<legend>Change Your Password</legend>
<p>Change Your Password<span style="background:#EAEAEA none repeat scroll 0 0;line-height:1;margin-left:210px;;padding:5px 7px;"></span> </p>
<div class="elements">
<label for="Password">Old Password:</label>
<input type="password" id="old_password" name="old_password" required size="25" />
</div>
<div class="elements">
<label for="Password">New Password:</label>
<input type="password" id="update_password" name="update_password" required size="25" />
<br>
<span style="font-size: 90%; color:#A4A4A4">(Must be 6 atleast characters)</span>
</div>
<div class="elements">
<label for="Password">Password Confirmation :</label>
<input type="password" id="Password" name="password_confirmation" required size="25" />
</div>
<div class="submit">
<input type="submit" value="Update" />
</div>
</form>
</body>
</html>
</div>
<br>
<?php
$path = $_SERVER['DOCUMENT_ROOT'];
$path .= "/includes/menu.php";
include_once($path);
$path = $_SERVER['DOCUMENT_ROOT'];
$path .= "/members/includes/footer.php";
include_once($path);
?>
[/syntax]
this is the backend file:
[syntax=php]<?php
$path = $_SERVER['DOCUMENT_ROOT'];
$path .= "/members/core/init.inc.php";
include_once($path);
if (isset($_POST['old_password'], $_POST['update_password'], $_POST['password_confirmation'])){
$errors = array();
if ($_POST["update_password"] == $_POST["password_confirmation"]) {
$errors[] = 'Passwords do not match.';
}
if (empty($errors)){
function update_password($update_password){
$update_password = md5($update_password);
$sql = "UPDATE
`trades`
SET
`password` = '{$update_password}'
WHERE
`id` = '{$_SESSION['id']}' ";
mysql_query($sql);
echo mysql_error();
if(mysql_query($sql)){
$message = '<h4>Successful</h4>';
}else{
$message = '<h4>Fail</h4>';
}
}
}
}else{
$message = '<h4 class="font1">Invalid Request</h4>';
echo mysql_error();
}[/syntax]
Could someone help me out with what I have done wrong or missed, as this doesn't do anything.
Thanks.
Password Reset for members.
- KnightMaire
- Posts: 29
- Joined: Thu May 05, 2011 9:03 pm
Re: Password Reset for members.
You are throwing an error if the passwords match, not if they don't match.