1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
|
<?php require_once('webadmin/basic_info.php');
$id = (int)$_SESSION["id"];
$campaign = get_campaign($id); check_campaign_date($campaign);
$message = "";
$gender = $_POST["gender"]; $_SESSION["gender"] = $gender;
$firstname = $_POST["firstname"]; $_SESSION["firstname"] = $firstname;
$lastname = $_POST["lastname"]; $_SESSION["lastname"] = $lastname;
if (isset($_POST["yyyy"])) { $_SESSION["yyyy"] = $_POST["yyyy"]; }
if (isset($_POST["mm"])) { $_SESSION["mm"] = $_POST["mm"]; }
if (isset($_POST["dd"])) { $_SESSION["dd"] = $_POST["dd"]; }
if (!empty($_POST["yyyy"]) && !empty($_POST["mm"]) && !empty($_POST["dd"])) { $dob = $_POST["yyyy"] . "-" . $_POST["mm"] . "-" . $_POST["dd"]; } else { $dob = ""; }
$email = $_POST["email"]; $_SESSION["email"] = $email;
$telephone = $_SESSION["telephone"]; //$_SESSION["telephone"] = $telephone;
if (isset($_POST["address"])) { $address = $_POST["address"]; $_SESSION["address"] = $_POST["address"]; } else { $address = ""; $_SESSION["address"] = ""; }
$district = $_POST["district"]; $district_name = $_POST["district_name"]; $_SESSION["district"] = $district; $_SESSION["district_name"] = $district_name;
$password = $_POST["password"]; $confirm_password = $_POST["confirm_password"];
$_SESSION['vCode'] = ""; if (empty($_POST["gender"]) || empty($_POST["firstname"]) || empty($_POST["lastname"]) || empty($_POST["dd"]) || empty($_POST["mm"]) || empty($_POST["yyyy"]) || empty($_POST["email"]) || empty($_SESSION["telephone"]) || empty($_SESSION["address"]) || empty($_POST["district"]) || empty($_POST["password"]) || empty($_POST["confirm_password"])) { $message .= "Missing required data. Please try again.\\n缺少必要的資料,請重新再嘗試。\\n\\n"; }
if (!filter_var($_POST["email"], FILTER_VALIDATE_EMAIL)) { $message .= "Email format is wrong.\\n電郵格式錯誤。\\n\\n"; }
if (!is_numeric($_SESSION["telephone"])) { $message .= "Mobile Phone should be digital number.\\n流動電話號碼應是數字。\\n\\n";
}
/*if(!empty($_POST["referencer_telephone"]) && !is_numeric($_POST["referencer_telephone"])){ $message .= "Referencer Telephone should be digital number.\\n\\n"; }*/
if ($_POST["password"] != $_POST["confirm_password"]) { $message .= "Password and confirm password should be same.\\n密碼和確認密碼必須相同。\\n\\n"; }
if (!isset($_POST["tnc"])) { $message .= "Please read and agree the terms & conditions. \\n請細閱及同意條款及細則。\\n\\n"; }
if (!checkdate($_POST["mm"], $_POST["dd"], $_POST["yyyy"])) { $message .= "Please choose correct date format.\\n"; }
/*if(!empty($_POST["referral_code"])){ if(!is_numeric($_POST["referral_code"])) { $message .= $_profile_post[4][$langcode]; }else { if($_POST["referral_code"] == $member_info["VIP_TEL"]){ $message .= $_profile_post[6][$langcode]; }else{ $sql = "select * from VIP where VIP_TEL = ? and VIP_TEL != ?"; $parameters = array($_POST["referral_code"], $member_info["VIP_TEL"]); $result = bind_pdo($sql, $parameters, "selectone");
if(empty($result)){ $message .= $_profile_post[5][$langcode]; } } } }*/
if (!empty($message)) { echo "<script>alert('" . $message . "'); history.back();</script>"; exit; }
//call api to check member info $url = $site_info["api_url"] . "check_vip_exist"; $postData = array("telephone" => $_SESSION["telephone"], "email" => $email); $post = 1; $check_member = call_curl($url, $postData, $post);
if ($check_member == 1) { //exist record $message = "Email or Telephone has been registered by others users.\\n電郵或流動電話已被登記。\\n\\n"; echo "<script>alert('" . $message . "'); history.back();</script>"; exit; } else { //valid user
//insert new member data to VIP //$url = 'http://sinomaxecomm.skytree.com.hk/api/vip/register'; $url = $site_info["skytree_api_hostname"] . 'api/vip/eShopRegister'; $postData = array('tel' => $telephone, 'lastname' => $lastname, 'firstname' => $firstname, 'birthday' => $dob, 'email' => $email, 'address' => $address, 'password' => $password, 'gender' => $gender, 'district_id' => $district); $result = call_curl($url, $postData, 1);
$result_array = json_decode($result, true);
if ($result_array["error"] == "0" && !empty($result_array["vip_code"])) { //has referral /*if(!empty($_POST["referral_code"])){ $url = $site_info["skytree_api_hostname"].'api/vip/submitReferCode'; $postData = array('vip_code' => $result_array["vip_code"], 'refer_code' => $_POST["referral_code"]); $result = call_API($url, $postData, 1); }*/
//unset session unset($_SESSION["account_verified"]); unset($_SESSION["registration_step2"]); unset($_SESSION["gender"]); unset($_SESSION["firstname"]); unset($_SESSION["lastname"]); unset($_SESSION["yyyy"]); unset($_SESSION["mm"]); unset($_SESSION["dd"]); unset($_SESSION["email"]); unset($_SESSION["telephone"]); unset($_SESSION["address"]); unset($_SESSION["district"]); unset($_SESSION["district_name"]);
echo "<script>alert('Registration Successfully. Please login to get rewards\\n註冊成功。登入後可以領取獎勵。\\n\\n'); window.location.href='user_info.php';</script>"; } else { //call api to remove VIPVerifingTel data when error
$url = $site_info["api_url"] . "remove_verify_tel"; $postData = array("telephone" => $_POST["telephone"]); $post = 1; $result = call_curl($url, $postData, $post);
echo "<script>alert('Error Occur: " . $result_array["error"] . " (" . $result_array["err_msg"] . "), Please try again.'); history.back();</script>"; } }
|