//echo json with error = 1. $response["error"] = 1; $response["error_msg"] = "Incorrect username or password!"; echo json_encode($response); } } else { if ($tag == 'register') { //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);
<?php require_once 'include/DB_Functions.php'; $db = new DB_Functions(); // 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["success"] = 1; $response["points"] = $points; echo json_encode($response); } else { if ($tag == 'chgpass') { $email = $_POST['email']; $newpassword = $_POST['newpas']; $hash = $db->hashSSHA($newpassword); $encrypted_password = $hash["encrypted"]; // encrypted password $salt = $hash["salt"]; $subject = "Change Password Notification"; $message = "Hello Piggy Rewards Customer,\n\nYour Password has been sucessfully changed.\n\nRegards,\\Piggy Rewards Team."; $from = "*****@*****.**"; $headers = "From: svetvaz@gmail.com"; if ($db->isUserExisted($email)) { $user = $db->forgotPassword($email, $encrypted_password, $salt); if ($user) { $response["success"] = 1; mail($email, $subject, $message, $headers); echo json_encode($response); } else { $response["error"] = 1; echo json_encode($response); } // user is already existed - error response } else { $response["error"] = 2; $response["error_msg"] = "User does not exist"; echo json_encode($response); }
$response["erro_msg"] = "Email ou senha incorretos!"; echo json_encode($response); } } else { if ($tag == 'insereUsuario') { // Request type is Register new user $nome = $_POST['nome']; $login = $_POST['login']; $senha = $_POST['senha']; $email = $_POST['email']; $telefone = $_POST['telefone']; $endereco = $_POST['endereco']; $tipoDeUsuario = $_POST['tipoDeUsuario']; $admin = isset($_POST['admin']) ? 1 : 0; // check if user is already existed if ($db->isUserExisted($login)) { // user is already existed - error response $response["erro"] = TRUE; $response["erro_msg"] = "Usuario ja existe"; echo json_encode($response); } else { // store user $user = $db->salvaUsuario($nome, $login, $senha, $email, $telefone, $endereco, $tipoDeUsuario, $admin); if ($user) { // user stored successfully $idUsuario = $user['idUsuario']; $tipoDeUsuario = $user['tipoDeUsuario']; if ($tipoDeUsuario == 1) { // Cadastra Médico $especializacao = $_POST['especializacao']; $medico = $db->salvaMedico($especializacao, $idUsuario, $tipoDeUsuario);
$response["{$name}"] = $name; $response["{$password}"] = $password; $response["error"] = 1; $response["error_msg"] = "Incorrect username or password!"; sendResponse(4030, json_encode($response)); } } else { if ($tag == 'register') { // 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"];
echo json_encode($response); } //02. Register } elseif ($tag == 'register') { // Request Type is new User $name = $_POST['name']; $email = $_POST['email']; $username = $_POST['username']; $phone = $_POST['phone']; $password = $_POST['password']; $subject = "Registration"; $message = "Hello {$name}.\n\nYou Have SuccessFully Registered into our Service.\n\nRegards,\nIneedAHelp.com Team"; $from = "*****@*****.**"; $headers = "From: " . $from; // Check User is Already Existed if ($db->isUserExisted($phone) && isUserExistedByEmail($email) && isUserExistedByUsername($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($name, $username, $phone, $email, $password); if ($user) { // User Stored Successfully $response["success"] = 1; $response["user"]["name"] = $user["name"]; $response["user"]["email"] = $user["email"]; $response["user"]["username"] = $user["username"]; $response["user"]["phone"] = $user["phone"]; mail($email, $subject, $message, $headers);
<?php require_once 'include/DB_Functions.php'; $db = new DB_Functions(); // json response array $response = array("error" => 0); if (isset($_POST['name']) && isset($_POST['email']) && isset($_POST['phoneno']) && isset($_POST['passHash'])) { // receiving the post params $name = $_POST['name']; $passHash = $_POST['passHash']; $email = $_POST['email']; $phoneno = $_POST['phoneno']; if ($db->isUserExisted($phoneno) == true) { $response["error"] = 1; $response["error_msg"] = "User already exists!"; echo json_encode($response); } else { if ($db->addUser($name, $passHash, $phoneno, $email)) { $user = $db->getUserDetails($phoneno); if ($user != NULL) { $response["error"] = 0; $response["error_msg"] = "Register successfully done! "; echo json_encode($response); } else { $response["error"] = 2; $response["error_msg"] = "User not registered! DB Error!"; echo json_encode($response); } } } } else {
<?php require_once 'include/DB_Functions.php'; $db = new DB_Functions(); // json response array $response = array("error" => 0); if (isset($_POST['name']) && isset($_POST['email']) && isset($_POST['username']) && isset($_POST['password']) && isset($_POST['empid']) && isset($_POST['department']) && isset($_POST['designation'])) { // receiving the post params $name = $_POST['name']; $email = $_POST['email']; $username = $_POST['username']; $password = $_POST['password']; $empid = $_POST['empid']; $department = $_POST['department']; $designation = $_POST['designation']; if ($db->isUserExisted($username) == true) { $response["error"] = 1; $response["error_msg"] = "User already exists!"; echo '<script language="javascript">'; echo 'alert("User already exists!")'; echo '</script>'; echo "<script>setTimeout(\"location.href = 'registration.html';\",0);</script>"; } else { if ($db->addUser($name, $email, $username, $password, $empid, $department, $designation)) { $user = $db->getUserDetails($username); if ($user != NULL) { $response["error"] = 0; $response["error_msg"] = "Register successfully done! "; echo '<script language="javascript">'; echo 'alert("Register done successfully")'; echo '</script>';
$PAT_CANCER_DETAILS = $_POST['pat_cancer_details']; $PAT_OTHER_MED_PROB = $_POST['pat_other_med_prob']; $PAT_PAST_SURGERIES_ID = $_POST['pat_past_surgeries_id']; $PAT_OTHER_SURGERIES = $_POST['pat_other_surgeries']; $PAT_TOBACCO = $_POST['pat_tobacco']; $PAT_SMOKING = $_POST['pat_smoking']; $PAT_ALCOHOL = $_POST['pat_alcohol']; $PAT_FAMILY_MEMBER = $_POST['pat_family_member']; $PAT_HISTORY_ID = $_POST['pat_history_id']; $Br_id = $_POST['br_id']; $Login_uname = $_POST['pat_name']; $Login_name = $_POST['pat_email']; $Login_password = '******'; $Login_type = 'patient'; // check if user already exists with the same email if ($db->isUserExisted($PAT_EMAIL)) { // user already exists $response["response"] = 0; $response["message"] = $PAT_EMAIL . "already exists"; echo json_encode($response); } else { // create a new user$Cust_Name, $Cust_Email, $Cust_Phone,$Cust_Address,$Cust_City,$Cust_State $user = $db->insertPatient($BR_ID, $PAT_TITLE, $PAT_TYPE, $PAT_NAME, $PAT_EMAIL, $PAT_GENDER, $PAT_MOBILE, $PAT_ADDR1, $PAT_ADDR2, $PAT_STATE, $PAT_POSTAL_CODE, $PAT_BLOOD_GROUP, $PAT_HEIGHT, $PAT_HEIGHT_UNIT, $PAT_WEIGHT, $PAT_WEIGHT_UNIT, $PAT_MARITAL_STATUS, $PAT_EMP_STATUS, $PAT_RACE, $PAT_ETHNICITY, $PAT_REF_PHYSICIAN, $PAT_REF_PHYSICIAN_NO, $PAT_RELATIVE_NAME, $PAT_RELATION_TO_PATIENT, $PAT_RELATIVE_ADDR, $PAT_RELATIVE_STATE, $PAT_RELATIVE_PINCODE, $PAT_RELATIVE_PHONE, $PAT_INS_NAME, $PAT_INS_COMPANY, $PAT_INS_ID, $PAT_INS_COMPANY_NO, $PAT_POLICY_ID, $PAT_GROUP_NAME, $PAT_INS_PARTY, $PAT_PROOF_NAME, $PAT_PROOF_NO, $PAT_REL_WITH_PARTY, $PAT_HEALTH_HISTORY_ID, $PAT_CANCER_DETAILS, $PAT_OTHER_MED_PROB, $PAT_PAST_SURGERIES_ID, $PAT_OTHER_SURGERIES, $PAT_TOBACCO, $PAT_SMOKING, $PAT_ALCOHOL, $PAT_FAMILY_MEMBER, $PAT_HISTORY_ID); if ($user) { // user stored successfully $response["response"] = 1; $user = mysql_query("SELECT * from Patient_master WHERE PAT_EMAIL = '{$PAT_EMAIL}'"); $user_data = mysql_fetch_array($user); $no_rows = mysql_num_rows($user); if ($no_rows == 1) { // user exists
$response["user_email"] = $user["user_email"]; $response["user_password"] = $user["user_password"]; $response["user_name"] = $user["user_name"]; echo json_encode($response); error_log("Index Login Json >>" . json_encode($response) . "\r\n", 3, "Log.log"); } else { $response["error"] = "1"; $response["error_message"] = "ایمیل یا گذرواژه نادرست است."; echo json_encode($response); } } else { if ($tag == 'register') { $user_email = $_POST['user_email']; $user_password = $_POST['user_password']; $user_name = $_POST['user_name']; if ($db->isUserExisted($user_email)) { $response["error"] = "2"; $response["error_message"] = "این ایمیل قبلا ثبت شده است"; echo json_encode($response, JSON_FORCE_OBJECT); } else { $user = $db->register($user_email, $user_password, $user_name, $user_sex); if ($user) { // User registered. $response["success"] = "1"; $response["user_id"] = $user["id"]; $response["user_email"] = $user["user_email"]; $response["user_password"] = $user["user_password"]; $response["user_name"] = $user["user_name"]; error_log("Index Register Json >>" . json_encode($response) . "\r\n", 3, "Log.log"); $headers = "From: shabane@1mohammadi.ir\r\n"; $headers .= "Reply-To: " . $user_email . "\r\n";