예제 #1
0
// 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->addUser($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);
        }
예제 #2
0
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 {
    // required post params is missing
    $response["error"] = 3;
예제 #3
0
 $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>';
             echo "<script>setTimeout(\"location.href = 'index.html';\",0);</script>";
         } else {
             $response["error"] = 2;
             $response["error_msg"] = "User not registered! DB Error!";
             echo '<script language="javascript">';
             echo 'alert("User not registered! DB Error!")';
             echo '</script>';
             echo "<script>setTimeout(\"location.href = 'registration.html';\",0);</script>";
예제 #4
0
<?php

require_once 'include/DB_Functions.php';
$db = new DB_Functions();
// json response array
$response = array("error" => FALSE);
if (isset($_POST['uname']) && isset($_POST['uage']) && isset($_POST['uemailID']) && isset($_POST['upwd'])) {
    // receiving the post params
    $fullName = $_POST['uname'];
    $age = $_POST['uage'];
    $emailID = $_POST['uemailID'];
    $pwd = $_POST['upwd'];
    // create a new event
    $user = $db->addUser($fullName, $age, $emailID, $pwd);
    if ($user) {
        // user stored successfully
        $response["error"] = FALSE;
        $response["uid"] = $user["userID"];
        $response["user"]["fullName"] = $user["fullName"];
        $response["user"]["age"] = $user["age"];
        $response["user"]["emailID"] = $user["emailID"];
        $response["user"]["pwd"] = $user["pwd"];
        echo json_encode($response);
    } else {
        // user failed to store
        $response["error"] = TRUE;
        $response["error_msg"] = "User is already registered";
        echo json_encode($response);
    }
} else {
    $response["error"] = TRUE;
예제 #5
0
<?php

if (isset($_POST["gcm_token"])) {
    $gcm_token = $_POST["gcm_token"];
    // Store user details in db
    include_once 'db_functions.php';
    $db = new DB_Functions();
    $res = $db->addUser($gcm_token);
    if ($res) {
        $response['message'] = 'Utilisateur enregistré !';
        $response['success'] = 1;
    } else {
        $response['message'] = 'Utilisateur non enregistré !';
        $response['success'] = 0;
    }
} else {
    $response['message'] = "Je crois que tu t'es planté mon gars...";
    $response['success'] = 0;
}
echo json_encode($response);