-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathemail-process.php
More file actions
53 lines (42 loc) · 1011 Bytes
/
Copy pathemail-process.php
File metadata and controls
53 lines (42 loc) · 1011 Bytes
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("inc/functions.php");
if (!isset($_POST["submitForm"])) {
header("Location: recovery.php");
exit();
}
$_SESSION["submitForm"] = true;
if (isset($_SESSION["error"])) {
unset($_SESSION["error"]);
}
$_SESSION["error"] = array();
$required = array(
"email"
);
//Check required
foreach ($required as $value) {
if (!(isset($_POST[$value])) || $_POST[$value] == "") {
$_SESSION["error"][] = $value." is required";
}
}
//Validate email address
if (!filter_var($_POST["email"], FILTER_VALIDATE_EMAIL)) {
$_SESSION["error"][] = "Email address is invalid.";
}
if (count($_SESSION["error"]) > 0) {
header("Location: recovery.php");
exit();
}
else {
$user = new User();
if ($user->emailPass($_POST["email"])) {
unset($_SESSION["submitForm"]);
header("Location: email-success.php");
exit();
}
else {
$_SESSION["error"][] = "Email address couldn't be located";
header("Location: recovery.php");
exit();
}
}
?>