Current File : /home/inlingua/public_html/sales/ajax_change_password.php
<?php
session_start();
ob_start(); 
// Include the database connection details
require('dbConnection.php');

// Include common functions
require('commonFunc.php');

// Include common functions
require('globalVars.php');

// Include the table handler class
require('dbHandler.class.php');

// Setup table name, configuration and data entry form
$tableName = "sales_login";
$tableConf = $tableName . ".conf.php";
//$dataForm = $tableName . ".form.php";
//$viewForm = $tableName . ".view.php";

// Init and connect to database
$dbObject = new dbHandler();
$dbObject->setTableName($tableName);
$dbObject->setDbFieldList($dbFieldList);
$dbObject->setKeyFieldName("recNo");
$dbObject->connect();

// Retrieve parameters from request
//$dbObject->getDbFieldsFromRequest();

if($_REQUEST['newpass']!=$_REQUEST['currpass'])
{
echo "Current Password and old password not matched";
die();
}

// Records selection sql
$sqlQuery = "SELECT * FROM sales_login where user_id='".$_SESSION['uname']."' and password='".$_REQUEST['currpass']."'";

// Select records from table
$selectedRecords = $dbObject->Select($sqlQuery);


// If no records selected, print message
if (!$selectedRecords)
{	
echo "Old password is wrong";
//header("Location: changepass.php");
//header(Location :)
die();

}
if ($selectedRecords)
{	
$dbObject->setDbField("password",$_REQUEST['newpass']);
if ($dbObject->Update("recNo",$_SESSION['id']))
{
echo "Password change successfully";
//header("Location: changepass.php");
}
}


// Print navigation bar
?>