include("include/dbconnect.php");
include("include/constants.php");
include("include/primaryfunctions.php");
//resId=6&Cid=35
$act=$_REQUEST['actfrom'];
$page="vip";
$ImagePath1="profileimages/";
if($_GET['resId']!="")
{
$resId=$_GET['resId'];
}
if($_GET['Cid']!="")
{
$Cid=$_GET['Cid'];
}
if(isset($HTTP_POST_VARS['save']))
{
//Get the Form values
$txtuser=$HTTP_POST_VARS['txtUser'];
$txtpassword=$HTTP_POST_VARS['txtPassword'];
$txtconfirmpassword=$HTTP_POST_VARS['txtConfirmPassword'];
$txtfirst=$HTTP_POST_VARS['txtFirst'];
$txtlast=$HTTP_POST_VARS['txtLast'];
$txtcompany=$HTTP_POST_VARS['txtCompany'];
$txtabout= $HTTP_POST_VARS['txtAbout'];
$act=$HTTP_POST_VARS['actfrom'];
$varupload = $_FILES['varupload'];
//Postal Address
$txtpostcode1=$HTTP_POST_VARS['txtPostcode1'];
$txtpostcode2="";
$txtpostcity=$HTTP_POST_VARS['txtPostCity'];
$txtpoststate=$HTTP_POST_VARS['txtPostState'];
$txtpostzip=$HTTP_POST_VARS['txtPostZip'];
$txtpostcountry=$HTTP_POST_VARS['txtPostCountry'];
$toggle = $_POST['toggle_name'];
//Delivery Address
$chkdelivery = $HTTP_POST_VARS['chkDelivery'];
if( $HTTP_POST_VARS['chkDelivery']!="true" )
{
$txtdelicode1=$HTTP_POST_VARS['txtDelicode1'];
$txtdelicode2="";
$txtdeliCity=$HTTP_POST_VARS['txtDeliCity'];
$txtdelistate=$HTTP_POST_VARS['txtDeliState'];
$txtdelizip=$HTTP_POST_VARS['txtDeliZip'];
$txtdelicountry=$HTTP_POST_VARS['txtDeliCountry'];
}
if( $HTTP_POST_VARS['chkDelivery']=="true" )
{
$txtdelicode1=$HTTP_POST_VARS['txtPostcode1'];
$txtdelicode2="";
$txtdeliCity=$HTTP_POST_VARS['txtPostCity'];
$txtdelistate=$HTTP_POST_VARS['txtPostState'];
$txtdelizip=$HTTP_POST_VARS['txtPostZip'];
$txtdelicountry=$HTTP_POST_VARS['txtPostCountry'];
}
//if($txtdelicode2 != "")
//$deliveryaddress = $txtdelicode1."
".$txtdelicode2."
".$txtdeliCity."
".$txtdelistate."
".$txtdelizip."
".$txtdelicountry;
//else
$deliveryaddress = $txtdelicode1."
".$txtdeliCity."
".$txtdelistate."
".$txtdelizip."
".$txtdelicountry;
//if($txtpostcode2 != "")
//$postaladdress = $txtpostcode1."
".$txtpostcode2."
".$txtpostcity."
".$txtpoststate."
".$txtpostzip."
".$txtpostcountry;
//else
$postaladdress = $txtpostcode1."
".$txtpostcity."
".$txtpoststate."
".$txtpostzip."
".$txtpostcountry;
//Phone values
$txtbusinessph=$HTTP_POST_VARS['txtBusinessph'];
$txthomeph=$HTTP_POST_VARS['txtHomeph'];
//Fax & Email
$txtfax=$HTTP_POST_VARS['txtFax'];
$txtemail=$HTTP_POST_VARS['txtEmail'];
//$txtnotify = $HTTP_POST_VARS['rdoNotify'];
$regdate = date("Y-m-d");
if(!(isset($HTTP_POST_VARS['must_delete'])))
{
//Check For Duplication and insert
$UserCheckQuery="select * from ".CUSTOMER." where ucase(varUser) = '".strtoupper($txtuser)."'";
$UserCheckResult=mysql_query($UserCheckQuery);
if(mysql_num_rows($UserCheckResult)==0)
{
$activestatus = "Active";
$notify="Yes";
$insqry="insert into ".CUSTOMER." (varUser,varPassword,varDelivery,varFirst,varLast,varCompany,varabout,varPost1,varPost2,varPost3,varState,varPostcode,varCountry,varDelivery1,varDelivery2,varDelivery3,varDelistate,varDelipost,varDeliCountry,varPhone1,varPhone2,varFax,varEmail,varStatus,dtRegDate,varNotify,display_toggle) values('$txtuser',encode('$txtpassword','$adminkey'),'$chkdelivery','$txtfirst','$txtlast','$txtcompany','$txtabout','$txtpostcode1','$txtpostcode2','$txtpostcity','$txtpoststate','$txtpostzip','$txtpostcountry','$txtdelicode1','$txtdelicode2','$txtdeliCity','$txtdelistate','$txtdelizip','$txtdelicountry','$txtbusinessph','$txthomeph','$txtfax','$txtemail','$activestatus','$regdate','$notify','$toggle')";
//echo $insqry;
$insres = mysql_query($insqry)or die(mysql_error());
$id = mysql_insert_id();
if (isset($_FILES["varupload"]) && $_FILES["varupload"]["name"])
{
$imgnamemain=copyimageonly1($ImagePath1,$varupload);
$UpdateQry="UPDATE ".CUSTOMER." SET varupload='$imgnamemain' WHERE intCustomerId='$id'";
$selUpQry=mysql_query($UpdateQry) or die("Update error".mysql_error());
}
if($resId!="" && $Cid!="")
{
$instqry="insert into ".FRIENDS." (intCustomerId,intFriendId,varStatus,CreatedDatetime,intCouponId) values('$id','$Cid',0,Now(),'$resId')";
$instres = mysql_query($instqry)or die(mysql_error());
}
$act=$HTTP_POST_VARS['actfrom'];
$act_pr=$HTTP_POST_VARS['actfrom_pr'];
if($HTTP_POST_VARS['actfrom'] == "checkout")
{
$HTTP_SESSION_VARS['MerchantUsername'] = $txtuser;
$HTTP_SESSION_VARS['MerchantUserId'] = $id;
$HTTP_SESSION_VARS['MerchantUserMail'] = $txtemail;
header("Location:checkout.php?actfrom=checkout");
}
else
{
header("Location:userlogin.php?reglog=succ&actfrom_pr=$act_pr&CID=".$_GET['CID']."");
}
}
else
{
if($HTTP_POST_VARS['actfrom'] == "checkout")
{
header("Location:register.php?ex=err&actfrom=checkout");
}
else
{
header("Location:register.php?ex=err");
}
}
}
}
if($HTTP_POST_VARS['must_delete'] != "")
{
//Check For Duplication and insert
$UserCheckQuery="select * from ".CUSTOMER." where ucase(varUser) = '".strtoupper($txtuser)."' and intCustomerId <> ".$HTTP_SESSION_VARS['pharmretailID'];
$UserCheckResult=mysql_query($UserCheckQuery);
if(mysql_num_rows($UserCheckResult)==0){
$id = $HTTP_SESSION_VARS['MerchantUserId'];
//Update Member Details
$HTTP_SESSION_VARS["MerchantUserMail"] = $txtemail;
$updqry="update ".CUSTOMER." set varUser='$txtuser',varPassword=encode('$txtpassword','$adminkey'),varDelivery='$chkdelivery',varFirst='$txtfirst',varLast='$txtlast',varEmail='$txtemail',varCompany='$txtcompany',varPost1='$txtpostcode1',varPost2='$txtpostcode2',varPost3='$txtpostcity',varState='$txtpoststate',varPostcode='$txtpostzip',varCountry='$txtpostcountry',varDelivery1='$txtdelicode1',varDelivery2='$txtdelicode2',varDelivery3='$txtdeliCity',varDelistate='$txtdelistate',varDelipost='$txtdelizip',varDeliCountry='$txtdelicountry',varPhone1='$txtbusinessph',varPhone2='$txthomeph',varFax='$txtfax',varabout='$txtabout',display_toggle='$toggle' where intCustomerId='".$_GET['c_id']."'";
if (isset($_FILES["varupload"]) && $_FILES["varupload"]["name"])
{
$imgnamemain=copyimageonly1($ImagePath1,$varupload);
$UpdateQry="UPDATE ".CUSTOMER." SET varupload='$imgnamemain' WHERE intCustomerId='".$HTTP_SESSION_VARS['MerchantUserId']."'";
$selUpQry=mysql_query($UpdateQry) or die("Update error".mysql_error());
}
$HTTP_SESSION_VARS['MerchantUsername']=$txtuser;
$HTTP_SESSION_VARS['MerchantUserId']=$id;
$HTTP_SESSION_VARS['MerchantUserMail']=$txtemail;
//echo $updqry;
$updres=mysql_query($updqry)or die(mysql_error());
if($HTTP_POST_VARS['actfrom'] == "checkout"){
header("Location:checkout.php");
}
else{
header("Location:viewmember.php?mid=$id");
}
}
else{
$c_id = $HTTP_SESSION_VARS['MerchantUserId'];
if($HTTP_POST_VARS['actfrom'] == "checkout"){
header("Location:register.php?ex=err&c_id=$c_id&actfrom=checkout");
}
else{
header("Location:register.php?ex=err&c_id=$c_id");
}
}
}
//Get the member Details
if($HTTP_GET_VARS['c_id'] != ""){
if($HTTP_SESSION_VARS['MerchantUserMail'] == ""){
header("Location:login.php");
}
else{
$getqry = "select * from ".CUSTOMER." where intCustomerId = ".$HTTP_SESSION_VARS['MerchantUserId'];
$getres = mysql_query($getqry)or die(mysql_error());
$getarray = mysql_fetch_array($getres);
$first = $getarray['varFirst'];
$cususer = $getarray['varUser'];
$last = $getarray['varLast'];
$company = $getarray['varCompany'];
$company = $getarray['varCompany'];
$upload = $getarray['varupload'];
$post1 = $getarray['varPost1'];
$post2 = $getarray['varPost2'];
$post3 = $getarray['varPost3'];
$state = $getarray['varState'];
$postcode = $getarray['varPostcode'];
$country = $getarray['varCountry'];
$deli1 = $getarray['varDelivery1'];
$deli2 = $getarray['varDelivery2'];
$deli3 = $getarray['varDelivery3'];
$delistate = $getarray['varDelistate'];
$delipost = $getarray['varDelipost'];
$delicountry = $getarray['varDeliCountry'];
$phone1 = $getarray['varPhone1'];
$phone2 = $getarray['varPhone2'];
$mobile = $getarray['varMobile'];
$fax = $getarray['varFax'];
$remarks = addslashes($getarray['varabout']);
$email = $getarray['varEmail'];
$chkdelivery = $getarray['varDelivery'];
$notifymail = $getarray['varNotify'];
$updateaction = "Update";
$get_toggle = $getarray['display_toggle'];
//Get the Password
$PasswordQry = "select decode(varPassword,'$adminkey') as password from ".CUSTOMER." where intCustomerId=".$HTTP_SESSION_VARS['MerchantUserId'];
$PasswordRes = mysql_query($PasswordQry);
$PasswordArr = mysql_fetch_array($PasswordRes);
$cuspassword = $PasswordArr['password'];
}
}
else{
$first = "";
$cususer = "";
$last = "";
$company = "";
$company ="";
$upload="";
$post1 = "";
$post2 = "";
$post3 = "";
$state = "";
$postcode = "";
$country = "";
$deli1 = "";
$deli2 = "";
$deli3 = "";
$delistate = "";
$delipost = "";
$delicountry = "";
$phone1 = "";
$phone2 = "";
$mobile = "";
$fax = "";
$remarks = "";
$email ="";
$chkdelivery = "";
$updateaction = "Register";
$chkdelivery = "true";
}
?>