|
@ -3,6 +3,7 @@ session_start(); |
|
|
session_id(trim($_GET['sid'])); |
|
|
session_id(trim($_GET['sid'])); |
|
|
include_once './config.php'; |
|
|
include_once './config.php'; |
|
|
include_once './database.php'; |
|
|
include_once './database.php'; |
|
|
|
|
|
include_once './send_mail.php'; |
|
|
|
|
|
|
|
|
header("Access-Control-Allow-Origin: *"); |
|
|
header("Access-Control-Allow-Origin: *"); |
|
|
header("Content-Type: application/json; charset=UTF-8"); |
|
|
header("Content-Type: application/json; charset=UTF-8"); |
|
@ -18,6 +19,26 @@ $data = json_decode(file_get_contents("php://input")); |
|
|
$query = "SELECT * FROM `users` WHERE email = '".trim($data->email)."'"; |
|
|
$query = "SELECT * FROM `users` WHERE email = '".trim($data->email)."'"; |
|
|
$stmt = $conn->prepare($query); |
|
|
$stmt = $conn->prepare($query); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$toEmail = trim($data->email); |
|
|
|
|
|
$toName = trim($data->first_name)." ".trim($data->last_name); |
|
|
|
|
|
$subject = 'IoLovOlio - Registrazione'; |
|
|
|
|
|
$body = emailHeader(); |
|
|
|
|
|
|
|
|
|
|
|
$body .= "<tr><td colspan=\"4\" style=\"padding: 10px 20px\">Ciao ".$data->first_name."<br>". |
|
|
|
|
|
"Grazie per esserti registrato a IoLovOlio, di seguito un riepilogo dei tuoi dati:<br><br>". |
|
|
|
|
|
"Nome: ".$data->first_name."<br>". |
|
|
|
|
|
"Cognome: ".$data->last_name."<br>". |
|
|
|
|
|
"Indirizzo: ".$data->address."<br>". |
|
|
|
|
|
"Città: ".$data->city."<br>". |
|
|
|
|
|
"CAP: ".$data->zip_code."<br><br>". |
|
|
|
|
|
"Email/ID: ".$data->email."<br>". |
|
|
|
|
|
"Password: ".$data->password."<br>". |
|
|
|
|
|
"</td></tr>"; |
|
|
|
|
|
|
|
|
|
|
|
$body .= "<tr><td colspan=\"4\">Grazie,<br>Servizio Clienti Iolovolio<br><br></td></tr>"; |
|
|
|
|
|
$body .= emailFooter(); |
|
|
|
|
|
|
|
|
if($stmt->execute()) { |
|
|
if($stmt->execute()) { |
|
|
|
|
|
|
|
|
if($stmt->rowCount()) { |
|
|
if($stmt->rowCount()) { |
|
@ -29,21 +50,25 @@ if($stmt->execute()) { |
|
|
)); |
|
|
)); |
|
|
} else { |
|
|
} else { |
|
|
|
|
|
|
|
|
$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, |
|
|
|
|
|
"id" => $conn->lastInsertId() |
|
|
|
|
|
)); |
|
|
|
|
|
|
|
|
$sent = sendEmail($toEmail, $toName, $subject, $body); |
|
|
|
|
|
if($sent === true) { |
|
|
|
|
|
|
|
|
|
|
|
$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, |
|
|
|
|
|
"id" => $conn->lastInsertId() |
|
|
|
|
|
)); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} else { |
|
|
} else { |
|
|