Commit 25d2f431 authored by Paarth's avatar Paarth

register functionality added

parent c2a01f47
<?php
include_once("database.php");
$postData = file_get_contents("php://input");
if (isset($postData) && !empty($postData)) {
$request = json_decode($postData);
$name = trim($request->name);
$pwd = password_hash(mysqli_real_escape_string($mysqli, trim($request->pwd)), PASSWORD_DEFAULT);
$email = mysqli_real_escape_string($mysqli, trim($request->email));
$username = mysqli_real_escape_string($mysqli, trim($request->username));
$sql = "INSERT INTO users(name,password,email,username) VALUES ('$name','$pwd','$email','$username')";
if ($mysqli->query($sql) === TRUE) {
$authData = [
'name' => $name,
'pwd' => $pwd,
'email' => $email,
'id' => mysqli_insert_id($mysqli),
'username' => $username
];
echo json_encode($authData);
} else {
echo "mysqli_error($mysqli)";
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment