-
Notifications
You must be signed in to change notification settings - Fork 0
/
check-user-exists.php
34 lines (30 loc) · 979 Bytes
/
check-user-exists.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
<?php
require_once "./logindb.php";
$db = pg_connect($connection_string) or die('Impossibile connettersi al database!');
if (isset($_POST['signup-email'])) {
$signup_email = trim($_POST['signup-email']);
// Verifica se l'e-mail è nel formato corretto.
if (!filter_var($signup_email, FILTER_VALIDATE_EMAIL)) {
echo "Non disponibile";
pg_close($db);
exit();
}
// Verifica la disponibilità della e-mail.
$sql = 'SELECT * FROM "user" WHERE email = $1';
$result = pg_prepare($db, "Check-User-Exists", $sql);
if (!$result) {
echo pg_last_error($db);
} else {
$result = pg_execute($db, "Check-User-Exists", array($signup_email));
if (!$result) {
echo pg_last_error($db);
} else {
if ($row = pg_fetch_assoc($result)) {
echo "Non disponibile";
} else {
echo "Disponibile";
}
}
}
}
pg_close($db);