-
Notifications
You must be signed in to change notification settings - Fork 0
/
login.php
executable file
·67 lines (44 loc) · 1.17 KB
/
login.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
61
62
63
64
65
66
67
<?php
ob_start();
session_start();
require_once("includes/header.php");
require_once("includes/form.php");
require_once("includes/customer.php");
require_once("includes/cart.php");
$oForm = new Form();
if(isset($_POST["submit"])==true){
$oForm->data = $_POST;
$oForm->checkRequired("Email");
$oForm->checkRequired("Password");
$oCheckCustomer = new Customer();
$bLoaded = $oCheckCustomer->loadByEmail($_POST["Email"]);
if($bLoaded == false){
$oForm->raiseCustomError("Email",'<p class="validate">Bad Email!</p>');
}else{
if($oCheckCustomer->Password != $_POST["Password"]){
$oForm->raiseCustomError("Password",'<p class="validate">Bad Password!</p>');
}
}
if($oForm->valid == true){
$_SESSION['CustomerID'] = $oCheckCustomer->CustomerID;
$oCart = new Cart();
// // $oCart->add(1);
// // $oCart->add(5);
// // $oCart->add(5);
// // $oCart->add(4);
$_SESSION["cart"] = $oCart;
//redirect
header("Location:my_account.php");
exit;
}
}
$oForm->makeTextInput("Email","Email");
$oForm->makePasswordInput("Password","Password");
$oForm->makeSubmit("Log In");
?>
<?php
echo $oForm->html;
?>
<?php
require_once("includes/footer.php");
?>