$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"]; // mail($email,$subject,$message,$headers); echo json_encode($response); } else { // user failed to store $response["error"] = 1; $response["error_msg"] = "JSON Error occured in Registration";
<?php // response json $json = array(); /** * Registering a user device * Store reg id in users table */ if (isset($_POST["gcm_user_mobile_id"]) && isset($_POST["regId"])) { // Store user details in db include_once './db_functions.php'; include_once './GCM.php'; $db = new DB_Functions(); $gcm = new GCM(); $res = $db->storeUser($_POST["gcm_user_mobile_id"], $_POST["regId"]); $registatoin_ids = array($gcm_regid); $message = array("product" => "shirt"); $result = $gcm->send_notification($registatoin_ids, $message); echo $result; } else { // user details missing }
/** * Registering a user device * Store reg id in users table */ $body = file_get_contents('php://input'); $postvars = json_decode($body, true); if (isset($postvars["name"]) && isset($postvars["email"]) && isset($postvars["regId"])) { $name = $postvars["name"]; $email = $postvars["email"]; $gcm_regid = $postvars["regId"]; // GCM Registration ID // Store user details in db include_once './db_functions.php'; include_once './GCM.php'; $db = new DB_Functions(); // $gcm = new GCM(); $res = $db->storeUser($name, $email, $gcm_regid); if ($res) { $response["status"] = "ok"; $response["message"] = "Register success!"; echo json_encode($response); } else { $response["status"] = "false"; $response["error"] = "Registration token is existed!"; echo json_encode($response); } } else { $response["status"] = "false"; $response["error"] = "Param include: name, email, token"; echo json_encode($response); }
// Request type is Register new user $name = $_POST['name']; $email = $_POST['email']; $password = $_POST['password']; $age = $_POST['age']; $sex = $_POST['sex']; // check if user is already existed if ($db->isUserExisted($name)) { // user is already existed - error response $responseError = array("error_msg" => "User already existed"); // $response["error"] = 2; // $response["error_msg"] = "User already existed"; sendResponse(4042, json_encode($responseError)); } else { // store user $user = $db->storeUser($name, $email, $password, $age, $sex); if ($user) { // user stored successfully $response["success"] = 1; $response["username"] = $user["unique_id"]; $response["email"] = $user["email"]; $response["age"] = $user["age"]; $response["sex"] = $user["sex"]; $response["created_at"] = $user["created_at"]; $response["updated_at"] = $user["updated_at"]; if (($_FILES["file"]["type"] == "image/gif" || $_FILES["file"]["type"] == "image/jpeg" || $_FILES["file"]["type"] == "image/pjpeg") && $_FILES["file"]["size"] < 2000000) { if ($_FILES["file"]["error"] > 0) { $response["error"] = 1; $response["error_msg"] = "Return Code: " . $_FILES["file"]["error"]; sendResponse(2004, json_encode($response)); } else {
// Request type is Register new user $username = $_POST['username']; $password = $_POST['password']; $email = $_POST['email']; $name = $_POST['name']; $city = $_POST['city']; $type = $_POST['type']; // check if user is already existed if ($db->isUserExisted($username)) { // user is already existed - error response $response["error"] = 1; $response["error_msg"] = "User already existed"; echo json_encode($response); } else { // store user $result = $db->storeUser($username, $password, $email, $name, $city, $type); if ($result != false) { while ($row = mysql_fetch_assoc($result)) { $user[] = $row; } echo json_encode($user); } else { // user failed to store $response["error"] = 1; $response["error_msg"] = "Error occured in Registartion"; echo json_encode($response); } } } else { if ($tag == 'change_info_user') { $username = $_POST['username'];
} else { if ($tag == 'register') { // Request type is Register new user $name = $_POST['name']; $email = $_POST['email']; $branch = $_POST['branch']; $year = $_POST['year']; // check if user is already existed if ($db->isUserExisted($email)) { // user is already existed - error response $response["error"] = 2; $response["error_msg"] = "User already existed"; echo json_encode($response); } else { // store user $user = $db->storeUser($name, $email, $branch, $year); if ($user) { // user stored successfully $response["success"] = 1; $response["uid"] = $user["unique_id"]; $response["user"]["name"] = $user["name"]; $response["user"]["email"] = $user["email"]; $response["user"]["branch"] = $user["branch"]; $response["user"]["year"] = $user["year"]; $response["user"]["created_at"] = $user["created_at"]; echo json_encode($response); } else { // user failed to store $response["error"] = 1; $response["error_msg"] = "Error occured in Registartion"; echo json_encode($response);
$date_n = $_POST['date_n']; $prix = $_POST['prix']; $img = $_POST['img']; $gouvernorat = $_POST['gouvernorat']; $matricule = $_POST['matricule']; $type = $_POST['type']; $marque = $_POST['marque']; // check if user is already existed with the same email if ($db->isUserExisted($email)) { // user already existed $response["error"] = TRUE; $response["error_msg"] = "User already existed with " . $email; echo json_encode($response); } else { // create a new user $user = $db->storeUser($name, $prenom, $cin, $email, $password, $img, $date_n, $gouvernorat, $prix); $vehic = $db->storeVehic($matricule, $marque, $type, $cin); if ($user) { // user stored successfully $response["error"] = FALSE; $response["user"]["nom"] = $user["nom"]; $response["user"]["email"] = $user["email"]; echo json_encode($response); } else { // user failed to store $response["error"] = TRUE; $response["error_msg"] = "Unknown error occurred in registration!"; echo json_encode($response); } } } else {
$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"]; $response["user"]["date_of_birth"] = $user["date_of_birth"]; $response["user"]["uid"] = $user["unique_id"]; $response["user"]["created_at"] = $user["created_at"]; mail($email_id, $subject, $message, $headers); echo json_encode($response); } else {
$email = $_POST['email']; $password = $_POST['password']; $gender = $_POST['gender']; $date = $_POST['date']; $month = converttomonth($_POST['month']); $year = $_POST['year']; $phone = $_POST['phone']; // check if user is already existed if ($db->isUserExisted($email)) { // user is already existed - error response $response["error"] = 2; $response["error_msg"] = "User already exits"; echo json_encode($response); } else { // store user $user = $db->storeUser($name, $email, $password, $gender, $date, $month, $year, $phone); if ($user) { $_SESSION['user'] = $user["unique_id"]; // user stored successfully $response["success"] = 1; $response["uid"] = $user["unique_id"]; $response["user"]["name"] = $user["name"]; $response["user"]["email"] = $user["email"]; $response["user"]["created_at"] = $user["created_at"]; $response["user"]["dob"] = $user["dob"]; $response["user"]["phone"] = $user["phone"]; setcookie("user", $user["unique_id"], time() + 3600); setcookie("isprofileok", 'false', time() + 3600); header("Refresh:0.1;"); //echo json_encode($response); //mail('*****@*****.**','Works!','An email has been generated from your localhost, congratulations!');
$email = $_POST['Email']; $password = $_POST['Password']; $first_name = $_POST['FirstName']; $last_name = $_POST['LastName']; $age = $_POST['Age']; $country = $_POST['Country']; $postal_code = $_POST['ZipCode']; // check if user is already existed if ($db->DoesUserExist($username)) { // user is already existed - error response $response["error"] = 2; $response["error_msg"] = "You already exist in out system!"; echo json_encode($response); } else { // store user $user = $db->storeUser($username, $email, $password, $first_name, $last_name, $age, $country, $postal_code); if ($user) { // user stored successfully $response["success"] = 1; $response["uid"] = $user["Uuid"]; $response["user"]["username"] = $user["Username"]; $response["user"]["email"] = $user["Email"]; $response["user"]["join_date"] = $user["JoinDate"]; $response["user"]["last_active_date"] = $user["LastActiveDate"]; $response["user"]["first_name"] = $user["FirstName"]; $response["user"]["last_name"] = $user["LastName"]; $response["user"]["age"] = $user["Age"]; $response["user"]["country"] = $user["Country"]; $response["user"]["postal_code"] = $user["ZipCode"]; echo json_encode($response); } else {
<?php // response json $json = array(); /** * Registering a user device * Store reg id in users table */ if (isset($_POST["regId"])) { $gcm_regid = $_POST["regId"]; include_once './db_functions.php'; include_once './gcm_sendmsg.php'; $db = new DB_Functions(); $gcm = new GCM_SendMsg(); $res = $db->storeUser($gcm_regid); $registatoin_ids = array($gcm_regid); $message = array("message" => $message, "timestamp" => "20-Jan-2016"); $result = $gcm->send_notification($registatoin_ids, $message); echo $result; } else { // required user details are not received }
// $uid =$bld.$rand; // check if user is already existed with the same email if ($db->isUserExisted($username)) { // user already existed $response["error"] = TRUE; $response["error_msg"] = "User already existed with " . $username; echo json_encode($response); } else { if ($db->isNumberExisted($phone)) { // user already existed $response["error"] = TRUE; $response["error_msg"] = "Phone Number already existed with " . $phone; echo json_encode($response); } else { // create a new user $user = $db->storeUser($name, $lname, $username, $password, $dob, $blood, $gender, $phone, $email, $district, $street); // $sts = $db->verify($status); if ($user) { // user stored successfully $response["error"] = FALSE; $response["uid"] = $user["user_id"]; $response["user"]["name"] = $user["first_name"]; $response["user"]["username"] = $user["user_name"]; $response["user"]["created_at"] = $user["joined_date"]; // $response["user"]["updated_at"] = $user["updated_at"]; echo json_encode($response); } else { // user failed to store $response["error"] = TRUE; $response["error_msg"] = "Unknown error occurred in registration!"; echo json_encode($response);
if (!isset($uid)) { $uid = "7777"; } if (!isset($user)) { $user = "******"; } /** * ผู้ใช้ลงทะเบียนอุปกรณ์เข้ากับฐานข้อมูล * โดยเก็บค่า reg id ลงในตาราง */ if (isset($my)) { $gcm_regid = $my; // GCM ID ที่ลงทะเบียน // เชื่อมต่อฐานข้อมูลและเก็บรายละเอียดผู้ใช้ลงฐานข้อมูล include_once './db_functions.php'; include_once './gcm.php'; $db = new DB_Functions(); $gcm = new GCM(); if ($db->getUser($gcm_regid)) { $res = $db->storeUser($gcm_regid, $uid, $user); $registatoin_ids = array($gcm_regid); $message = "ยินดีต้อนรับสู่ Smart OBEC"; $result = $gcm->send_notification($registatoin_ids, $message); //echo "gcm regid".$gcm_regid; echo $result; } else { echo "ผู้ใช้ลงทะเบียนแล้ว"; } } else { echo "ไม่มีค่า my " . $my; }
$response = array("error" => FALSE); if (isset($_POST['first_name']) && isset($_POST['last_name']) && isset($_POST['email']) && isset($_POST['password']) && isset($_POST['contact_no'])) { $first_name = $_POST['first_name']; $last_name = $_POST['last_name']; $email = $_POST['email']; $password = $_POST['password']; $contact_no = $_POST['contact_no']; $facebook_link = $_POST['facebook_link']; $twitter_link = $_POST['twitter_link']; //check if user is already there if ($db->isUserExisted($email)) { $response["error"] = TRUE; $response["error_msg"] = "User already exists with email " . $email; echo json_encode($response); } else { $user = $db->storeUser($first_name, $last_name, $email, $password, $contact_no, $facebook_link, $twitter_link); echo "\n" . $user["name"]; if ($user) { $response["error"] = FALSE; $response["uid"] = $user["unique_id"]; $response["user"]["First_name"] = $user["first_name"]; $response["user"]["Last_name"] = $user["last_name"]; $response["user"]["Contact"] = $user["contact_no"]; $response["user"]["email"] = $user["email"]; $response["user"]["Fadebook_link"] = $user["facebook_link"]; $response["user"]["Twitter_link"] = $user["twitter_link"]; $response["user"]["created_at"] = $user["created_at"]; $response["user"]["updated_at"] = $user["updated_at"]; echo json_encode($response); } else { $response["error"] = TRUE;
file_put_contents("updates_log.log", $result, FILE_APPEND | LOCK_EX); die('0'); } if (isset($_POST["name"]) && isset($_POST["email"]) && isset($_POST["regId"])) { $name = $_POST["name"]; $email = $_POST["email"]; $gcm_regid = $_POST["regId"]; // GCM Registration ID $lang = isset($_POST["lang"]) ? $_POST["lang"] : "unkown"; $region = isset($_POST["region"]) ? $_POST["region"] : "unkown"; // Store user details in db include_once './db_functions.php'; include_once './GCM.php'; $db = new DB_Functions(); $gcm = new GCM(); $res = $db->storeUser($name, $email, $gcm_regid, $region, $lang); $registatoin_ids = array($gcm_regid); include './sharedkeys.php'; $xml = new SimpleXMLElement('<data/>'); $xml->addChild('title', "Welcome"); $xml->addChild('description', "Thank you for installing the app you will now receive a notifications that carries the most amazing news , places and other stuff."); $image = $xml->addChild('images'); $link = $image->addChild('link'); $link->addChild('image', PROJECT_URL . "1.JPG"); $link->addChild('thum', PROJECT_URL . "thum_1.JPG"); $link = $image->addChild('link'); $link->addChild('image', PROJECT_URL . "2.JPG"); $link->addChild('thum', PROJECT_URL . "thum_2.JPG"); $link = $image->addChild('link'); $link->addChild('image', PROJECT_URL . "3.JPG"); $link->addChild('thum', PROJECT_URL . "thum_3.JPG");
<?php // response json $json = array(); /** * Registering a user device * Store reg id in users table */ if (isset($_POST["token"]) && isset($_POST["regId"])) { $token = $_POST["token"]; $gcm_regid = $_POST["regId"]; // GCM Registration ID // Store user details in db include_once './db_functions.php'; include_once './GCM.php'; $db = new DB_Functions(); $gcm = new GCM(); $res = $db->storeUser($token, $gcm_regid); $registatoin_ids = array($gcm_regid); $message = array("product" => "shirt"); $result = $gcm->send_notification($registatoin_ids, $message); echo $result; } else { // user details missing }
<?php header('Access-Control-Allow-Origin: *'); // response json $json = array(); /** * Registering a user device * Store reg id in users table */ function getPostData() { $data = json_decode(file_get_contents('php://input'), true); if ($data === null && count($_POST)) { $data = $_POST; } return $data; } $post = getPostData(); if (isset($post["device"]) && isset($post["regId"])) { $device = $post["device"]; $gcm_regid = $post["regId"]; // GCM Registration ID // Store user details in db include_once './db_functions.php'; include_once './gcm.php'; $db = new DB_Functions(); $gcm = new GCM(); $db->storeUser($device, $gcm_regid); echo 'success'; }
// Request type is Register new user $name = $_POST['name']; $nric = $_POST['nric']; $phone = $_POST['phone']; $email = $_POST['name']; $username = $_POST['username']; $password = $_POST['password']; // check if user is already existed if ($db->isUserExisted($username)) { // user is already existed - error response $response["error"] = TRUE; $response["error_msg"] = "User already existed"; echo json_encode($response); } else { // store user $user = $db->storeUser($name, $nric, $phone, $email, $username, $password); if ($user) { // user stored successfully $response["error"] = FALSE; $response["user"]["account_id"] = $user["account_id"]; $response["user"]["name"] = $user["name"]; $response["user"]["nric"] = $user["nric"]; $response["user"]["phone"] = $user["phone"]; $response["user"]["email"] = $user["email"]; $response["user"]["profpic"] = $user["profpic"]; echo json_encode($response); } else { // user failed to store $response["error"] = TRUE; $response["error_msg"] = "Error occured in Registration"; echo json_encode($response);
if ($tag == 'register') { // Request type is Register new user $username = $_POST['username']; $firstname = $_POST['firstname']; $lastname = $_POST['lastname']; $email = $_POST['email']; $password = $_POST['password']; // check if user is already existed if ($db->isUserExisted($email)) { // user is already existed - error response $response["error"] = TRUE; $response["error_msg"] = "User already existed"; echo json_encode($response); } else { // store user $user = $db->storeUser($username, $firstname, $lastname, $password, $email, $created_at); if (is_array($user)) { // user stored successfully $response["error"] = 0; $response["uid"] = $user["uid"]; $response["user"]["username"] = $user["username"]; $response["user"]["firstname"] = $user["firstname"]; $response["user"]["lastname"] = $user["lastname"]; $response["user"]["password"] = $user["password"]; $response["user"]["email"] = $user["email"]; $response["user"]["created_at"] = $user["created_at"]; echo json_encode($response); //file_put_contents('resp_reg_ok.txt',json_encode($response)); } else { // user failed to store $response["error"] = 1;
$email = $_POST['email']; $username = $_POST['username']; $password = $_POST['password']; $age = $_POST['age']; $sex = $_POST['sex']; $weight = $_POST['weight']; $gcm_regid = $_POST['gcm_regid']; // check if user is already existed if ($db->isUserExisted($username)) { // user is already existed - error response $response["error"] = 2; $response["error_msg"] = "Username already existed"; echo json_encode($response); } else { // store user $user = $db->storeUser($name, $phone, $address, $email, $username, $password, $age, $sex, $weight, $gcm_regid); if ($user) { // user stored successfully $response["success"] = 1; $response["id"] = $user["id"]; $response["user"]["name"] = $user["name"]; $response["user"]["phone"] = $user["phone"]; $response["user"]["address"] = $user["address"]; $response["user"]["email"] = $user["email"]; $response["user"]["username"] = $user["username"]; $response["user"]["age"] = $user["age"]; $response["user"]["sex"] = $user["sex"]; $response["user"]["weight"] = $user["weight"]; $response["user"]["gcm_regid"] = $user["gcm_regid"]; //$registatoin_ids = array($gcm_regid); //$message = array("signup" => "Hello "+ $user["name"] + ", Registration Successful");
<?php if (isset($_GET["name"]) && isset($_GET["contact"]) && isset($_GET["reg_id"])) { $name = $_GET["name"]; $contact = $_GET["contact"]; $gcm_regid = $_GET["reg_id"]; include_once 'db_functions.php'; $db = new DB_Functions(); $res = $db->storeUser($name, $contact, $gcm_regid); if ($res) { echo "success"; } else { echo "failure"; } } else { // user details missing echo "missing"; }
if ($tag == "storeCompleteUser") { $hash = password_hash($password, PASSWORD_DEFAULT); $store = $db->storeCompleteUser($user_id, $firstname, $lastname, $email, $hash); if ($store) { $response["success"] = 1; } else { $response["error"] = 1; $response["error_msg"] = "Could not register user"; } echo json_encode($response); } else { if ($tag == "storeUser") { $userExists = $db->isUserExisting($user_id); if (!$userExists) { // $hash = password_hash($password, PASSWORD_DEFAULT); $bool = $db->storeUser($user_id, $firstname, $lastname); if ($bool) { $response["success"] = 1; } else { $response["error"] = 1; $response["error_msg"] = "Error, could not register"; } } else { $bool = $db->updateUser($user_id, $email, $firstname, $lastname, $debt, $block, $lobare); if ($bool) { $response["success"] = 1; $response["tag"] = "updateUser"; } else { $response["error"] = 1; $response["error_msg"] = "Could not update user"; }
<?php // response json $json = array(); /** * Registering a user device * Store reg id in users table */ if (isset($_POST["contactID"]) && isset($_POST["regId"]) && isset($_POST["deviceId"])) { $userID = $_POST["contactID"]; $deviceId = $_POST["deviceId"]; //$email = $_POST["email"]; $gcm_regid = $_POST["regId"]; // GCM Registration ID // Store user details in db include_once 'db_functions.php'; include_once 'GCM.php'; $db = new DB_Functions(); $gcm = new GCM(); $res = $db->storeUser($userID, $gcm_regid, $deviceId); $registatoin_ids = array($gcm_regid); $message = array("Response" => "msg"); $result = $gcm->send_notification($registatoin_ids, $message); echo $result; } else { // user details missing }
} } else { if ($tag == 'register') { // Request type is Register new user $name = $_POST['name']; $email = $_POST['email']; $username = $_POST['username']; // check if user is already existed if ($db->isUserExisted($email)) { // user is already existed - error response $response["error"] = 2; $response["error_msg"] = "User already existed"; echo json_encode($response); } else { // store user $user = $db->storeUser($name, $email, $username); if ($user) { // user stored successfully $response["success"] = 1; $response["uid"] = $user["unique_id"]; $response["user"]["name"] = $user["name"]; $response["user"]["email"] = $user["email"]; $response["user"]["created_at"] = $user["created_at"]; $response["user"]["updated_at"] = $user["updated_at"]; echo json_encode($response); } else { // user failed to store $response["error"] = 1; $response["error_msg"] = "Error occured in Registartion"; echo json_encode($response); }
$response = array("error" => FALSE); if (isset($_POST['firstname']) && isset($_POST['lastname']) && isset($_POST['email']) && isset($_POST['password'])) { // receiving the post params $firstname = trim($_POST['firstname']); $lastname = trim($_POST['lastname']); $email = trim($_POST['email']); $password = trim($_POST['password']); // check if user is already existed with the same email if ($db->isUserExisted($email)) { // user already existed $response["error"] = TRUE; $response["error_msg"] = "User already existed with " . $email; echo json_encode($response); } else { // create a new user $user = $db->storeUser($firstname, $lastname, $email, $password); if ($user) { // user stored successfully $response["error"] = FALSE; $response["user"]["user_ID"] = $user["user_ID"]; $response["user"]["firstname"] = $user["firstname"]; $response["user"]["lastname"] = $user["lastname"]; $response["user"]["date_added"] = $user["date_added"]; $response["user"]["email"] = $user["email"]; echo json_encode($response, JSON_UNESCAPED_UNICODE); } else { // user failed to store $response["error"] = TRUE; $response["error_msg"] = "Unknown error occurred in registration!"; echo json_encode($response); }
// json response array $response = array("error" => FALSE); if (isset($_POST['name']) && isset($_POST['email']) && isset($_POST['password'])) { // receiving the post params $name = $_POST['name']; $email = $_POST['email']; $password = $_POST['password']; // check if user is already existed with the same email if ($db->isUserExisted($email)) { // user already existed $response["error"] = TRUE; $response["error_msg"] = "User already existed with " . $email; echo json_encode($response); } else { // create a new user $user = $db->storeUser($name, $email, $password); if ($user) { // user stored successfully $response["error"] = FALSE; $response["uid"] = $user["unique_id"]; $response["user"]["name"] = $user["name"]; $response["user"]["email"] = $user["email"]; $response["user"]["created_at"] = $user["created_at"]; $response["user"]["updated_at"] = $user["updated_at"]; echo json_encode($response); } else { // user failed to store $response["error"] = TRUE; $response["error_msg"] = "Unknown error occurred in registration!"; echo json_encode($response); }
<td>Address:</td><td><input text="address" /></td></tr> <tr> <td>Age:</td><td><input text="age" /></td></tr> <tr> <td>Gender</td><td><input text="gender" /></td></tr> <tr><td colspan="2" align="center"><input type="submit" value="Add User"/></td></tr> </table> </form> <?php include_once './db_functions.php'; //Create Object for DB_Functions clas if (isset($_POST["username"]) && !empty($_POST["username"])) { $db = new DB_Functions(); //Store User into MySQL DB $uname = $_POST["username"]; $res = $db->storeUser($uname); //Based on inserttion, create JSON response if ($res) { ?> <div id="msg">Insertion successful</div> <?php } else { ?> <div id="msg">Insertion failed</div> <?php } } else { ?> <div id="msg">Please fill up all informaton needed and submit</div> <?php }
//Request type is Register new user $username = $_POST['username']; $password = $_POST['password']; $subject = "Registration"; $message = "Hello {$username},nnYou have sucessfully registered to our service.nnRegards,nAdmin."; $from = "balah balah"; $headers = "From:" . $from; //Check if user is already existed if ($db->isUserExisted($username)) { // user is already existed - error response $response["error"] = 2; $response["error_msg"] = "User already existed"; echo json_encode($response); } else { //Store user $user = $db->storeUser($username, $password); //print_r($user); if ($user) { //user store successfully $response["success"] = 1; $response["user"]["username"] = $user["username"]; //$response["user"]["password"] = $user["encrypted_passwd"]; $response["user"]["created"] = $user["created"]; //mail($email,$subject,$message,$headers); echo json_encode($response); } else { // user failed to store $response["error"] = 1; $response["error_msg"] = "JSON Error occured in Registartion"; echo json_encode($response); }
$undergradGpa = floatval($_POST['undergradGpa']); $greQuant = floatval($_POST['greQuant']); $greVerbal = floatval($_POST['greVerbal']); $greAWA = floatval($_POST['greAWA']); $engScore = floatval($_POST['engScore']); $workExp = floatval($_POST['workExp']); $greTotal = floatval($greQuant + $greVerbal); // check if user is already existed with the same username if ($db->isUserExisted($username)) { // user already existed $response["error"] = TRUE; $response["error_msg"] = "User already exists with " . $username; echo json_encode($response); } else { // create a new user $user = $db->storeUser($username, $password, $fullname, $emailId, $courseInterest, $undergradGpa, $greQuant, $greVerbal, $greAWA, $greTotal, $engScore, $workExp); if ($user) { // user stored successfully $response["error"] = FALSE; $response["user"]["username"] = $user["username"]; echo json_encode($response); } else { // user failed to store $response["error"] = TRUE; $response["error_msg"] = "Unknown error occurred in registration!"; echo json_encode($response); } } } else { $response["error"] = TRUE; $response["error_msg"] = "Required parameters (username, name, email or password) is missing!";