<?php
include("includes/site_info.php");
$ConfirmSign = 0;
include('session_handler.inc');
	
	switch ($_REQUEST["Mode"]) {
	case "putInfo"; 
		putInfo();
		break;
	case "editPayee"; 
		editPayee();
		break;
	case "editContact"; 
		editContact();
		break;
	default; 
		echo "";
		break;
	}

function putInfo () {
	global $CONST_LINK_ROOT, $SITE_MAIN_WWW_ROOT;

	$_REQUEST['status' ] ='0';
	$return = array('status' => '0');
//	print_r($_REQUEST);

	$WUserID = $_REQUEST['userid'];
	$payeename = htmlspecialchars($_REQUEST['payeename'], ENT_QUOTES);
	$town = htmlspecialchars($_REQUEST['address'], ENT_QUOTES);
	$city = htmlspecialchars($_REQUEST['city'], ENT_QUOTES);
	$state = htmlspecialchars($_REQUEST['state'], ENT_QUOTES);
	$country = (int)$_REQUEST['country'];
	$zipcode = htmlspecialchars($_REQUEST['zipcode'], ENT_QUOTES);
	$fullname = htmlspecialchars($_REQUEST['fullname'], ENT_QUOTES);
	$email = htmlspecialchars($_REQUEST['email'], ENT_QUOTES);
	$mobile = htmlspecialchars($_REQUEST['mobile'], ENT_QUOTES);
	$nickname = htmlspecialchars($_REQUEST['nickname'], ENT_QUOTES);

	$sql="Insert into market_Account set mem_userid='$WUserID', mem_PayeeName='$payeename', mem_PayeeTown='$town', mem_PayeeCity='$city', mem_PayeeState='$state', mem_PayeeCountry='$country', mem_PayeeZipcode='$zipcode', mem_ContactName='$fullname', mem_ContactEmail='$email', mem_ContactMobile='$mobile', mem_AccountNick='$nickname', mem_joindate=now()";
	$squery=mysql_query($sql);

if (!$squery) {
	$return['error'] = 'Database Error!';
} else {
	$return['status'] ='1';
	$return['success'] = 'Account Created successfully!';
	$_SESSION['startPost'] = "new";
}

echo json_encode($return);
exit;
}


function editPayee () {
	global $CONST_LINK_ROOT, $SITE_MAIN_WWW_ROOT;

	$_REQUEST['status' ] ='0';
	$return = array('status' => '0');
//	print_r($_REQUEST);

	$WUserID = $_REQUEST['userid'];
	$payeename = htmlspecialchars($_REQUEST['payeename'], ENT_QUOTES);
	$town = htmlspecialchars($_REQUEST['address'], ENT_QUOTES);
	$city = htmlspecialchars($_REQUEST['city'], ENT_QUOTES);
	$state = htmlspecialchars($_REQUEST['state'], ENT_QUOTES);
	$country = (int)$_REQUEST['country'];
	$zipcode = htmlspecialchars($_REQUEST['zipcode'], ENT_QUOTES);

	$sql="UPDATE market_Account set mem_PayeeName='$payeename', mem_PayeeTown='$town', mem_PayeeCity='$city', mem_PayeeState='$state', mem_PayeeCountry='$country', mem_PayeeZipcode='$zipcode' where mem_userid='$WUserID'";
	$squery=mysql_query($sql);

if (!$squery) {
	$return['error'] = 'Database Error!';
} else {
	$return['status'] ='1';
	$return['success'] = 'Account updated successfully!';
}

echo json_encode($return);
exit;
}


function editContact () {
	global $CONST_LINK_ROOT, $SITE_MAIN_WWW_ROOT;

	$_REQUEST['status' ] ='0';
	$return = array('status' => '0');
//	print_r($_REQUEST);

	$WUserID = $_REQUEST['userid'];
	$fullname = htmlspecialchars($_REQUEST['fullname'], ENT_QUOTES);
	$email = htmlspecialchars($_REQUEST['email'], ENT_QUOTES);
	$mobile = htmlspecialchars($_REQUEST['mobile'], ENT_QUOTES);

	$sql="UPDATE market_Account set mem_ContactName='$fullname', mem_ContactEmail='$email', mem_ContactMobile='$mobile' where mem_userid='$WUserID'";
	$squery=mysql_query($sql);

if (!$squery) {
	$return['error'] = 'Database Error!';
} else {
	$return['status'] ='1';
	$return['success'] = 'Account updated successfully!';
}

echo json_encode($return);
exit;
}
?>
