<?php
session_start();
include("include/db.conn.php");
include("include/admin.class.php");
include("include/conf.class.php");
global $cartCore;
if(isset($_POST['passwordResetSubmit']) && !empty($_POST['oldpassword']) && !empty($_POST['newpassword'])){
		
		$username=$cartCore->md5_base64_decode($cartCore->ClearInput($_POST['username']));
		$encrypt_oldpassword=$cartCore->md5_pure_encode($_POST['oldpassword']);
		$encrypt_newpassword=$cartCore->md5_pure_encode($_POST['newpassword']);
		
		$userinfo=$cartCore->get_user_info($username);
		
		if($encrypt_oldpassword==$userinfo['PASSWORD'])
		{
			$cartCore->update_user_password($username,$encrypt_newpassword); 
			echo 'ok';
		}
		else
		{
			echo 'err';
		}
		
	 }
	 

if(isset($_POST['profileEditSubmit']) && !empty($_POST['FULLNAME']) && !empty($_POST['ADDRESS']) && !empty($_POST['USERID']) && !empty($_POST['COUNTRY']) && !empty($_POST['TELEPHONE']) && !empty($_POST['EMAIL'])){
		
		$USERID=$cartCore->md5_base64_decode($cartCore->ClearInput($_POST['USERID']));
		$FULLNAME=$cartCore->ClearInput($_POST['FULLNAME']);
		$ADDRESS=$cartCore->ClearInput($_POST['ADDRESS']);
		$COUNTRY=$cartCore->ClearInput($_POST['COUNTRY']);
		$TELEPHONE=$cartCore->ClearInput($_POST['TELEPHONE']);
		$EMAIL=$cartCore->ClearInput($_POST['EMAIL']);

			$cartCore->update_customer_profile($USERID,$FULLNAME,$ADDRESS,$COUNTRY,$TELEPHONE,$EMAIL);
			$cartCore->update_user_profile($USERID,$FULLNAME,$EMAIL); 
			echo 'ok';
		
		
	 }
	 else
	 {
		 echo 'err';
	 }
	 