Exemplo n.º 1
0
     } else {
         // user not found
         // echo json with error = 1
         $response["error"] = TRUE;
         $response["error_msg"] = "Incorrect email or password!";
         echo json_encode($response);
     }
 } else {
     if ($tag == 'register') {
         // Request type is Register new user
         $name = $_POST['name'];
         $email = $_POST['email'];
         $password = $_POST['password'];
         $role = $_POST['role'];
         // 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($name, $email, $password, $role);
             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"]["role"] = $user["role"];
                 $response["user"]["created_at"] = $user["created_at"];
Exemplo n.º 2
0
<?php

//include '../skglfunction/db_connector.php';
require_once 'db_functions.php';
require_once 'config.php';
$db = new db_functions();
$name = htmlspecialchars($_POST['name']);
$username = htmlspecialchars($_POST['username']);
$pass = htmlspecialchars($_POST['password']);
$mobile_no = htmlspecialchars($_POST['mobileno']);
$password = hash('sha256', USER_SALT . hash('sha256', $pass));
$response = array("error" => FALSE);
if ($db->isUserExisted($username)) {
    $response["error"] = TRUE;
    $response["error_msg"] = "User already existed with " . $username;
    echo json_encode($response);
} else {
    $sql = "insert into tbl_register(fname,username,password,mobileno) values('{$name}','{$username}','{$password}','{$mobile_no}')";
    $result = @mysql_query($sql);
    $response["error"] = FALSE;
    echo json_encode($response);
}
Exemplo n.º 3
0
<?php

require_once 'db_functions.php';
$db = new db_functions();
if ($db->isUserExisted("sahan")) {
    $response["error"] = TRUE;
    $response["error_msg"] = "User already existed with " . $username;
    echo json_encode($response);
} else {
    $response["error"] = FALSE;
    echo json_encode($response);
}