This repository has been archived by the owner on Oct 9, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathregistrati_handler.php
53 lines (52 loc) · 2.99 KB
/
registrati_handler.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
49
50
51
52
53
<?php
require_once "PHP/class.php";
session_start();
if (isset($_SESSION["username"])) {
header("Location: index.php");
} else {
if (isset($_POST["pass_reg2"], $_POST["pass_reg"], $_POST["username_reg"], $_POST["email_reg"])) {
//REGEX email è valida
$okemail = true;
if (!filter_var($_POST["email_reg"], FILTER_VALIDATE_EMAIL)) {
$_SESSION["error_email"] = $_POST["email_reg"];
$_SESSION["error_email2"] = "<img id=\"emailNOT_disponibile\" src=\"img/Xrossa.png\" alt=\"Errore nell'inserimento della email.\" height=\"15px\" width=\"15px\" role=\"alert\"/>";
$okemail = false;
} else {
$result2 = Access::checkEmail($_POST["email_reg"]);
}
//REGEX username ha solo lettere e spazi
$okuser = true;
if (!preg_match('/^[a-zA-Z0-9]{4,}$/', $_POST["username_reg"])) {
$_SESSION["error_user"] = $_POST["username_reg"];
$_SESSION["error_user2"] = "<img id=\"usernameNOT_disponibile\" src=\"img/Xrossa.png\" alt=\"Errore nell'inserimento dello username.\" height=\"15px\" width=\"15px\" role=\"alert\" />";
$okuser = false;
} else {
$result = Access::checkUsern($_POST["username_reg"]);
}
if (!isset($result) && !isset($result2) && $okemail && $okuser) {
if ($_POST["pass_reg2"] == $_POST["pass_reg"] && strlen($_POST["pass_reg"]) >= 4 && strlen($_POST["pass_reg"]) <= 16) {
$resultReg = Access::registraNuovoUtente($_POST["pass_reg"], $_POST["username_reg"], $_POST["email_reg"]);
if (isset($resultReg) && $resultReg) {
$_SESSION['reg_eff'] = '<div class="change-success" role="alert">Registazione avvenuta con successo.</div>';
header("Location: accesso.php");
} else {
$_SESSION["genericError"] = '<div id="msgchange" class="change-error" role="alert">Errore nella creazione dell\'account, riprova più tardi.</div>';
}
} else {
$_SESSION["error_pass"] = "<img id=\"passNOT_disponibile\" src=\"img/Xrossa.png\" alt=\"Le password non corrispondono\" height=\"15px\" width=\"15px\" role=\"alert\" />";
}
}
if (isset($result)) {
$_SESSION["error_user"] = $result;
$_SESSION["error_user2"] = "<img id=\"usernameNOT_disponibile\" src=\"img/Xrossa.png\" alt=\"Username non disponibile.\" height=\"15px\" width=\"15px\" role=\"alert\" />";
}
if (isset($result2)) {
$_SESSION["error_email"] = $result2;
$_SESSION["error_email2"] = "<img id=\"emailNOT_disponibile\" src=\"img/Xrossa.png\" alt=\"Email non disponibile.\" height=\"15px\" width=\"15px\" role=\"alert\" />";
}
}
if (isset($result) && isset($result2) && !isset($resultReg) && !($_POST["pass_reg2"] == $_POST["pass_reg"] && strlen($_POST["pass_reg"]) >= 4 && strlen($_POST["pass_reg"]) <= 16)) {
header("Location: registrazione.php");
}
}
?>