Esempio n. 1
0
 function __construct()
 {
     require_once 'DB_Connect.php';
     // connecting to database
     $db = new Db_Connect();
     $this->conn = $db->connect();
 }
 function __construct()
 {
     require_once dirname(__FILE__) . '/DB_Connect.php';
     // connecting to database
     $db = new Db_Connect();
     $this->conn = $db->connect();
 }
Esempio n. 3
0
 function __construct()
 {
     require_once 'DB_Connect.php';
     // connecting to database
     $db = new Db_Connect();
     $this->conn = $db->connect();
     // $this->uid = $this->generateUniqueId();
 }
<?php

//require_once ($_SERVER['DOCUMENT_ROOT'].'/include/DB_Functions.php');
require_once 'include/DB_Connect.php';
$db = new Db_Connect();
$conn = $db->connect();
$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'];
    $uuid = uniqid('', true);
    /**
     * Encrypting password
     * @param password
     * returns salt and encrypted password
     */
    $salt = sha1(rand());
    $salt = substr($salt, 0, 10);
    $encrypted = base64_encode(sha1($password . $salt, true) . $salt);
    $sql = "INSERT INTO users(unique_id, name, email, encrypted_password, salt, created_at) VALUES('{$uuid}','{$name}', '{$email}', '{$encrypted}', '{$salt}', NOW())";
    if (mysqli_query($conn, $sql)) {
        echo "new record is successfull";
        $get_data = "SELECT * FROM users WHERE email = '{$email}'";
        $result = mysqli_query($conn, $get_data);
        if (mysqli_num_rows($result) > 0) {
            while ($row = mysqli_fetch_assoc($result)) {
                $response["error"] = FALSE;
                $response["uid"] = $row["unique_id"];
                $response["user"]["name"] = $row["name"];