12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- <?php
- require $_SERVER['DOCUMENT_ROOT']. '/services/connect.php';
- $_POST = json_decode(file_get_contents('php://input'), true);
- $name = $_POST["name"];
- $surname = $_POST["surname"];
- $address = $_POST["address"];
- $email = $_POST["email"];
- $password = $_POST["password"];
- $hash = password_hash($password, PASSWORD_DEFAULT);
- $query = "INSERT INTO users (`name`, `surname`, `address`, `email`, `password`)" .
- " VALUES ('$name', '$surname', '$address', '$email', '$hash')";
- $result = $mysql->query($query);
- if(!$result){
- echo "Произошли неполадки: ". $mysql->error;
- }
- //Response
- $query = "SELECT * FROM users WHERE `email` = '$email' ";
- $result = $mysql->query($query);
- if(!$result){
- echo "Произошли неполадки: ". $mysql->error;
- }
- $id = $result->fetch_assoc()["id"];
- $data = [
- "id" => $id,
- "name" => $name,
- "surname" => $surname,
- "address" => $address,
- "email" => $email,
- "rezult" => true,
- ];
- header('Content-Type: application/json; charset=utf-8');
- echo json_encode($data);
- ?>
|