-
Notifications
You must be signed in to change notification settings - Fork 0
/
register.php
48 lines (41 loc) · 1.4 KB
/
register.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<?php
require_once "DB_Functions.php";
$db = new DB_Functions();
// json response array
$response = array("error" => false);
if (isset($_POST["nome"]) && isset($_POST["cognome"]) && isset($_POST["email"]) && isset($_POST["password"]))
{
$nome = $_POST["nome"];
$cognome = $_POST["cognome"];
$email = $_POST["email"];
$password = $_POST["password"];
if ($db->emailAlreadyUsed($email))
{
$response["error"] = true;
$response["error_msg"] = "L'email inserita è già in uso, riprova.";
}
else
{
$user = $db->storeUser($nome, $cognome, $email, $password);
if ($user)
{
require_once "Helper_Functions.php";
$helper = new Helper_Functions();
$response["user"] = $user;
$result = $helper->sendEmail($user["email"], $user["nome"], $user["codice_conferma"]);
$response["email"] = $result;
}
else
{
$response["error"] = true;
$response["error_msg"] = "Si è verificato un errore imprevisto durante l'inserimento del nuovo utente";
}
}
}
else
{
$response["error"] = true;
$response["error_msg"] = "I parametri richiesti sono obbligatori";
}
echo json_encode($response);
?>