i made a script to change the password
if i file in the form i get a message that my password is changed
but it doesnt :'(
please help me
thanks in advanced
if($_POST['submit']=='Set')
{
// If the change form has been submitted
$err = array();
$usr = $_SESSION['usr'];
$newpass = $_POST['newpass'];
$passorig = mysql_query("SELECT pass FROM tz_mebers WHERE usr=$usr");
$email = mysql_query("SELECT email FROM tz_mebers WHERE usr=$usr");
if(!$_POST['oldpassword'] == $passorig)
{
$err[]='Your password is incorrect!';
}
if(!$_POST['newpass'] == $_POST['vnewpass'])
{
$err[]='Your passwords do not match!';
}
if(!count($err))
{
// If there are no errors
$pass = md5($_POST['newpassword']);
// Generate a random password
$_POST['newpassword'] = mysql_real_escape_string($_POST['newpassword']);
// Escape the input data
mysql_query("UPDATE tz_members SET pass=$newpass WHERE usr=$usr");
send_mail( '
[email protected]',
$email,
'ClephasWebdesign member registration - Your New Password',
'Your password is: '.$pass);
$_SESSION['msg']['cha-success']='Your password is set succesfull!';
}
if(count($err))
{
$_SESSION['msg']['cha-err'] = implode('<br />',$err);
}
header("Location: home.php");
exit;
}
<form action="" method="post">
<h1>Change Your Password</h1>
<?php
if($_SESSION['msg']['cha-err'])
{
echo '<div class="err">'.$_SESSION['msg']['cha-err'].'</div>';
unset($_SESSION['msg']['cha-err']);
}
if($_SESSION['msg']['cha-success'])
{
echo '<div class="success">'.$_SESSION['msg']['cha-success'].'</div>';
unset($_SESSION['msg']['cha-success']);
}
?>
<label class="grey" >Old Password:</label>
<input class="field" type="password" name="oldpass" id="oldpass" value="" size="23" />
<label class="grey" >New Password:</label>
<input class="field" type="password" name="newpass" id="newpass" value="" size="23" />
<label class="grey" >Verify New Password:</label>
<input class="field" type="password" name="vnewpass" id="vnewpass" value="" size="23" />
<input type="submit" name="submit" value="Set" class="bt_register"/>
</form>