diff --git a/api/user_add.php b/api/user_add.php
index 55706bc..4fe5dcd 100644
--- a/api/user_add.php
+++ b/api/user_add.php
@@ -3,6 +3,7 @@ session_start();
session_id(trim($_GET['sid']));
include_once './config.php';
include_once './database.php';
+include_once './send_mail.php';
header("Access-Control-Allow-Origin: *");
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)."'";
$stmt = $conn->prepare($query);
+
+ $toEmail = trim($data->email);
+ $toName = trim($data->first_name)." ".trim($data->last_name);
+ $subject = 'IoLovOlio - Registrazione';
+ $body = emailHeader();
+
+ $body .= "
Ciao ".$data->first_name." ".
+ "Grazie per esserti registrato a IoLovOlio, di seguito un riepilogo dei tuoi dati:
".
+ "Nome: ".$data->first_name." ".
+ "Cognome: ".$data->last_name." ".
+ "Indirizzo: ".$data->address." ".
+ "Città: ".$data->city." ".
+ "CAP: ".$data->zip_code."
".
+ "Email/ID: ".$data->email." ".
+ "Password: ".$data->password." ".
+ " |
";
+
+ $body .= "Grazie, Servizio Clienti Iolovolio
|
";
+ $body .= emailFooter();
+
if($stmt->execute()) {
if($stmt->rowCount()) {
@@ -29,21 +50,25 @@ if($stmt->execute()) {
));
} 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 {
diff --git a/components/account/account.js b/components/account/account.js
index 75801b5..8faeb2f 100644
--- a/components/account/account.js
+++ b/components/account/account.js
@@ -104,7 +104,7 @@ $(document).ready( () => {
grecaptcha.ready(() => {
grecaptcha.execute(ENV.RECAPTCHA_SITE_KEY, {action: 'submit'}).then((token) => {
Apis.addUser(body).then( (data) => {
- Apis.notification("Account aggiunto correttamente!")
+ Apis.notification("Account aggiunto correttamente!
Riceverai una mail di conferma all'indirizzo indicato.")
}).catch( (error) => {
console.error(error)
Apis.notification("ATTENZIONE: L'utente che stai cercando di inserire è già presente nel database")
diff --git a/src/js/index.js b/src/js/index.js
index 5766164..250c3a1 100644
--- a/src/js/index.js
+++ b/src/js/index.js
@@ -184,7 +184,7 @@ window.Apis.saveOrder = (profile, cart, token, uid, total, paid = false) => {
window.Apis.notification = (text) => {
const notification = $('.notification')
- notification.text(text).fadeIn(10, () => {
+ notification.html(text).fadeIn(10, () => {
setTimeout(() => {
notification.fadeOut(300)
},5000)
diff --git a/src/scss/global.scss b/src/scss/global.scss
index ba3f806..105efc8 100644
--- a/src/scss/global.scss
+++ b/src/scss/global.scss
@@ -181,9 +181,9 @@ button {
@keyframes blink {
0% { opacity: 1; }
- 25% { opacity: .6; }
+ 25% { opacity: .7; }
50% { opacity: 1; }
- 75% { opacity: .6; }
+ 75% { opacity: .7; }
100% { opacity: 1; }
}