<?php
/**
 * @author freddy
 * @copyright 2009
 */
session_start();

require('dbconnect.php'); 

$userid = $_SESSION['MM_Username'];
$password = $_POST['password'];
$newpassword = $_POST['newpass'];
$confirmnewpassword = $_POST['cnewpass'];

$result = mysql_query("SELECT password FROM ibank WHERE `customernum` = '$userid'");
if(!$result)
{ 
session_regenerate_id();
$_SESSION['SESS_INVALPASS'] = "$userid , you entered an Invalid Password";
session_write_close();
} 
else
if($newpassword==$confirmnewpassword) 
    $sql=mysql_query("UPDATE ibank SET `password`='$newpassword' where `customernum` = '$userid'"); 
    if($sql) 
    { 
session_regenerate_id();
$_SESSION['SESS_PASSCHANGED'] = "Password reset successful";
session_write_close();
    }
	header('location: cbdchangepass.php');
?>