-
Notifications
You must be signed in to change notification settings - Fork 5
/
login.php
109 lines (96 loc) · 4 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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
<?php
session_start();
require ("function.php");// Including the db Connection
?>
<html lang="en">
<head>
<title>E-Commerce</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script>$().alert()
$(".alert").alert()</script>
</head>
<body>
<nav class="navbar navbar-inverse" style="border-radius:0px;">
<div class="container-fluid">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#myNavbar">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#">Logo</a>
</div>
<div class="collapse navbar-collapse" id="myNavbar">
<ul class="nav navbar-nav">
<li ><a href="home.php">Home</a></li>
<li><a href="menu.php">Food Menu</a></li>
<li><a href="stores.php">Stores</a></li>
<li><a href="contact.php">Contact</a></li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li style="top:7px;">
<form class="form-inline my-2 my-lg-0" method="get" action="results.php" enctype="multipart/form-data">
<input class="form-control" type="search" name="user_query" placeholder="Search" aria-label="Search">
<button class="btn btn-primary" name="search" type="submit">Search</button>
</form>
<li><a href="cart.php"><span class="glyphicon glyphicon-shopping-cart"></span> Cart</a></li>
</ul>
</div>
</div>
</nav>
<div class="container" align="center" >
<form class="form-signin" method="post" action="" style="width:450px; height:450px;">
<h2 class="form-signin-heading">Please sign in</h2><br>
<label for="inputEmail" class="sr-only">Email address</label>
<input type="email" id="inputEmail" name="email" class="form-control" placeholder="Email address" required="" autofocus=""><br>
<label for="inputPassword" class="sr-only">Password</label>
<input type="password" id="inputPassword" name="password" class="form-control" placeholder="Password" required="">
<div class="checkbox">
<label>
<input type="checkbox" value="remember-me"> Remember me
</label>
</div>
<button class="btn btn-primary btn-block" type="submit">Sign in</button>
<p class="h4">Not registered? <a href="register.php">Create an account</a></p>
</form>
</div> <!-- /container -->
</body>
</html>
<?php
if($_SERVER['REQUEST_METHOD'] == 'POST'){
$c_email = $_POST['email'];
$c_pass = $_POST['password'];
$sel_c = $conn->query('select *from customers where cust_pass="'.$c_pass.'" AND cust_email="'.$c_email.'"');
while($row = $sel_c->fetch(PDO::FETCH_ASSOC))
{
$cust_id = $row['cust_id'];
$name = $row['cust_dname'];
}
$check_customer = $sel_c->rowCount();
if($check_customer==0){
echo "<script>alert('Password or Email is incorrect,Please try again!')</script>";
exit();
}
$ip = getIp();
$sel_cart = $conn->query('select *from cart where ip_add="'.$ip.'"');
$row = $sel_cart->fetch(PDO::FETCH_ASSOC);
$check_cart = $sel_cart->rowCount();
if($check_customer>0 AND $check_cart==0){
$_SESSION['cust_id']= $cust_id;
$_SESSION['cust_name']= $name;
$_SESSION['cust_email']=$c_email;
echo "<script>window.open('menu.php','_self')</script>";
}
else
{
$_SESSION['cust_id']= $cust_id;
$_SESSION['cust_name']=$name;
$_SESSION['cust_email']=$c_email;
echo "<script>window.open('cart.php','_self')</script>";
}
}
?>