$lname = $_POST['lname']; $email = $_POST['email']; $uname = $_POST['uname']; $password = $_POST['password']; $subject = "Registration"; $message = "Hello {$fname},\n\nYou have sucessfully registered to the Piggy Rewards Loyalty program. You may begin using all of our services. \n\nRegards,\nAdmin, Loyalty Rewards Team."; $from = "*****@*****.**"; $headers = "From:" . $from; // check if user is already existed if ($db->isUserExisted($email)) { // user is already existed - error response $response["error"] = 2; $response["error_msg"] = "User already exists.Click on 'Forgot Password to retrieve your password'"; echo json_encode($response); } else { if (!$db->validEmail($email)) { $response["error"] = 3; $response["error_msg"] = "Invalid Email Id"; echo json_encode($response); } else { // store user $user = $db->storeUser($fname, $lname, $email, $uname, $password); if ($user) { // user stored successfully $response["success"] = 1; $response["user"]["fname"] = $user["firstname"]; $response["user"]["lname"] = $user["lastname"]; $response["user"]["email"] = $user["email"]; $response["user"]["uname"] = $user["username"]; $response["user"]["uid"] = $user["unique_id"]; $response["user"]["created_at"] = $user["created_at"];
$date_of_birth = $_POST['date_of_birth']; $security_question = $_POST['security_question']; $security_answer = $_POST['security_answer']; $user_password = $_POST['user_password']; $subject = "Registration"; $message = "Hello {$first_name},\n\nYou have sucessfully registered to our service.\n\nRegards,\nStampsHub."; $from = "*****@*****.**"; $headers = "From:" . $from; // check if user is already existed if ($db->isUserExisted($email_id)) { // user is already existed - error response $response["error"] = 2; $response["error_msg"] = "User already existed"; echo json_encode($response); } else { if (!$db->validEmail($email_id)) { $response["error"] = 3; $response["error_msg"] = "Invalid Email Id"; echo json_encode($response); } else { // store user $user = $db->storeUser($utype, $first_name, $last_name, $email_id, $user_gender, $phone_number, $date_of_birth, $security_question, $security_answer, $user_password); if ($user) { // user stored successfully $response["success"] = 1; $response["user"]["utype"] = $user["utype"]; $response["user"]["first_name"] = $user["first_name"]; $response["user"]["last_name"] = $user["last_name"]; $response["user"]["email_id"] = $user["email_id"]; $response["user"]["user_gender"] = $user["user_gender"]; $response["user"]["phone_number"] = $user["phone_number"];