bildungdb/api/registration.php
2023-01-08 22:45:34 +01:00

28 lines
839 B
PHP

<?php
include_once("db_config.php");
$postdata = file_get_contents("php://input");
$request = json_decode($postdata);
if(isset($postdata) && !empty($postdata))
{
$name = mysqli_real_escape_string($mysqli, trim($request->name));
$pwd = mysqli_real_escape_string($mysqli, (int)$request->pwd);
$email = mysqli_real_escape_string($mysqli, trim($request->email));
$datum = now();
$sql = "INSERT INTO user(login, name, password,email,created) VALUES ('{$login}',' {$name}','". password($pwd) . "','{$email}','{$datum}')";
echo $sql;
if ($mysqli->query($sql) === TRUE) {
$authdata = [
'name' => $name,
'pwd' => '',
'email' => $email,
'login' => $login,
'Id' => mysqli_insert_id($mysqli)
];
echo json_encode($authdata);
}
}