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

require('dbconnect.php'); 

$userid = $_SESSION['MM_Username'];
$password = $_POST['transpin'];
$newpassword = $_POST['newpin'];
$confirmnewpassword = $_POST['cnewpin'];

$result = mysql_query("SELECT transpin FROM ibank WHERE `customernum` = '$userid'");
if(!$result)
{ 
session_regenerate_id();
$_SESSION['SESS_INVALPIN'] = "you entered an Invalid PIN";
session_write_close();
} 
else
if($newpassword==$confirmnewpassword) 
    $sql=mysql_query("UPDATE ibank SET `transpin`='$newpassword' where `customernum` = '$userid'"); 
    if($sql) 
    { 
session_regenerate_id();
$_SESSION['SESS_PINCHANGED'] = "Login PIN reset successful";
session_write_close();
    }
	header('location: cbdchangepin.php');
?>