last create new file changepassword.php
and put this in it
<?
ob_start();
session_start();
if(!isset($_COOKIE["id"]))
{
header("Location: login.php");
}
else
{
session_start(); // Start Session
include("header.php");
//for testing
//if(!isset($_COOKIE["user"])){
//echo "<center><font face='Verdana' size='2' color=red>Sorry, Please login and use this page </font></center>";
//exit;
//}
$userb = $_COOKIE["user"];
$password1 = $_POST['password1'];
$password2 = $_POST['password2'];
if (!isset($_POST['password1'])) {
}
elseif (empty($password1) || empty($password2)) {
$empty_fields_message = "<font face='Verdana' size='2' color=red>Please complete all the fields in the form.</font>";//Click <a class=\"two\" href=\"javascript:history.go(-1)\">here</a> to go back";
}
else {
$db_password1=md5(mysql_real_escape_string($password1));
//Setting flags for checking
$status = "OK";
$msg="";
if ( strlen($password1) < 3 or strlen($password1) > 10 ){
$msg1= "Password must be more than 3 characters in length and maximum 10 characters in length<BR>";
$status= "NOTOK";}
if (strcmp( $password1,$password2 ) !=0){
$msg2="Both passwords do not match<BR>";
$status= "NOTOK";}
if($status<>"OK"){
$msg = "<font face='Verdana' size='2' color=red>$msg</font><br>";//<center><input type='button' value='Retry' onClick='history.go(-1)'></center>";
}else{ // if all validations are passed.
if(mysql_query("UPDATE pp_user SET pass='$db_password1' where user= '$userb'"));
{
$message = "<font face='Verdana' size='2' ><center>Thanks ". $userb ."<br> Your password changed successfully. <br> Please keep changing your password for better security<br></font>Your New Password is ". $password1."</center>";
}
}
}
$smarty->assign('message', $message);
$smarty->assign('empty_fields_message', $empty_fields_message);
$smarty->assign('msg', $msg);
$smarty->assign('msg1', $msg1);
$smarty->assign('msg2', $msg2);
$smarty->display('changepassword.tpl');
}
?>