6 changed files with 89 additions and 19 deletions
@ -0,0 +1,42 @@ |
|||||
|
<?php |
||||
|
session_start(); |
||||
|
include_once './config.php'; |
||||
|
include_once './database.php'; |
||||
|
|
||||
|
header("Access-Control-Allow-Origin: *"); |
||||
|
header("Content-Type: application/json; charset=UTF-8"); |
||||
|
header("Access-Control-Allow-Methods: POST"); |
||||
|
header("Access-Control-Max-Age: 3600"); |
||||
|
header("Access-Control-Allow-Headers: Content-Type, Access-Control-Allow-Headers, Authorization, X-Requested-With"); |
||||
|
|
||||
|
$databaseService = new DatabaseService(); |
||||
|
$conn = $databaseService->getConnection(); |
||||
|
|
||||
|
$data = json_decode(file_get_contents("php://input")); |
||||
|
|
||||
|
$query = "INSERT INTO `users` |
||||
|
(`id`, `first_name`, `last_name`, `email`, `phone`, `address`, `city`, `zip_code`, `province`, `password`) |
||||
|
VALUES (NULL, '".trim($data->first_name)."', '".trim($data->last_name)."', '".trim($data->email)."', |
||||
|
'".trim($data->phone)."', '".trim($data->address)."', '".trim($data->city)."', |
||||
|
'".trim($data->zip_code)."', '".trim($data->province)."', '".md5(trim($data->password))."')"; |
||||
|
|
||||
|
$stmt = $conn->prepare($query); |
||||
|
|
||||
|
if($stmt->execute()) { |
||||
|
http_response_code(200); |
||||
|
echo json_encode( |
||||
|
array( |
||||
|
"status" => 200, |
||||
|
"profile" => $data |
||||
|
)); |
||||
|
} else { |
||||
|
http_response_code(400); |
||||
|
echo json_encode( |
||||
|
array( |
||||
|
"status" => 400, |
||||
|
"message" => "Error inserting new user" |
||||
|
)); |
||||
|
} |
||||
|
|
||||
|
?> |
||||
|
|
Loading…
Reference in new issue