-
Notifications
You must be signed in to change notification settings - Fork 0
/
action.php
executable file
·60 lines (49 loc) · 1.25 KB
/
action.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
54
55
56
57
58
59
60
<?php
require_once $_SERVER['DOCUMENT_ROOT'].'/repos/todoApp/config.php';
session_start();
if(isset($_POST) && isset($_POST['type'])){
if($_POST['type']==="login")
{
//Verify the kind of form
if(empty($_POST['username']) || empty($_POST['password']))
{
$_SESSION['error'] = "Please fill mandatory fields.";
header('Location: index.php');
}
else
{
$username = $_POST['username'];
$password = $_POST['password'];
$users = new ManageUsers();
//Gets Success when verified
if($users->verifyUser($username, $password))
{
header('Location: home.php');
}
else
{
$_SESSION['error'] = "Username/password mismatch";
header('Location: index.php');
}
//If correct, redirect to todo app
}
}
else if($_POST['type']==="create")
{
$email= $_POST['email'];
$username= $_POST['username'];
$password= $_POST['password'];
$create = new Create($username, $email, $password);
try {
$create->create();
header('Location: home.php');
} catch (Exception $e) {
$_SESSION['error'] = $e->getMessage();
header('Location: index.php');
}
}
else if($_POST['type']==="reset")
{
//todo mail for reset
}
}