-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcustomer.php
151 lines (136 loc) · 4.52 KB
/
customer.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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
<?php
session_start();
$errormessage= "";
if($_POST){
if(array_key_exists('signup',$_POST)){
if($_POST['emailto'] == ''){
$errormessage.= "Email field cannot be empty"."<br>";
}
if($_POST['password1'] == ''){
$errormessage.= "Password cannot be empty"."<br>";
}
if (!filter_var($_POST['emailto'], FILTER_VALIDATE_EMAIL)) {
$errormessage.= "Enter Valid Email address"."<br>";
}
if($errormessage!=""){
$errormessage = "<div class='alert alert-danger' role='alert'>"."These were error(s) in your form:"."<br>".$errormessage."</div>";
}
else{
$link = mysqli_connect('localhost','root','','user');
if(mysqli_connect_error()){
die("Connection Unsuccessful!");
}
$password = md5($_POST['password1']);
$query = "INSERT INTO `users` (`Email`, `Password`) VALUES ('".mysqli_real_escape_string($link, $_POST['emailto'])."', '".mysqli_real_escape_string($link,$password)."')";
if(mysqli_query($link,$query)){
if(array_key_exists('cookie1',$_POST)){
setcookie("customerID","1234",time()+60*60*1);
}
$_SESSION['email'] = $_POST['emailto'];
header("Location: mainpage.php");
}
}
}
else if(array_key_exists('login',$_POST)){
if($_POST['emailto'] == ''){
$errormessage.= "Email field cannot be empty"."<br>";
}
if($_POST['password1'] == ''){
$errormessage.= "Password cannot be empty"."<br>";
}
if (!filter_var($_POST['emailto'], FILTER_VALIDATE_EMAIL)) {
$errormessage.= "Enter Valid Email address"."<br>";
}
if($errormessage!=""){
$errormessage = "These were error(s) in your form:"."<br>".$errormessage;
}
else{
$link = mysqli_connect('localhost','root','','user');
if(mysqli_connect_error()){
die("Connection Unsuccessful!");
}
$password = md5($_POST['password1']);
$query = "SELECT `Id` FROM `users` WHERE Email = '".mysqli_real_escape_string($link,$_POST['emailto'])."' AND Password = '".mysqli_real_escape_string($link,$password)."'";
$result = mysqli_query($link,$query);
if(mysqli_num_rows($result)>0){
if(array_key_exists('cookie1',$_POST)){
setcookie("customerID","1234",time()+60*60*1);
}
$_SESSION['email'] = $_POST['emailto'];
header("Location: mainpage.php");
}
else{
$errormessage.="<div class='alert alert-danger' role='alert'>"."Incorrect Email ID or Password"."</div>";
}
}
}
}
?>
<!DOCTYPE html>
<head>
<style>
ul {
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
background-color: #333;
}
li {
float: left;
}
li a {
display: block;
color: white;
text-align: center;
padding: 14px 16px;
font-size: 130%;
text-decoration: none;
}
li a:hover {
background-color: #111;
}
#logo{
margin-left: 450%;
font-size: 200%;
margin-top:-20px;
margin-bottom: -20px;
}
#X{
font-size: 160%;
color: red;
font-weight: bold;
}
</style>
</head>
<html style="background: url(img/customerbg.PNG) no-repeat center center fixed; -webkit-background-size:cover; -moz-background-size: cover; -o-background-size: cover; background-size: cover;">
<title>Seller's Dashboard</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<body>
<ul>
<li><a class="active" href="#home">Home</a></li>
<li><a href="#news">News</a></li>
<li><a href="#contact">Contact</a></li>
<li><a href="#about">About</a></li>
<li><a href="logo" id="logo">Mede<span id = "X">X</span></a>
</ul>
<center>
<div class="w3-container w3-card-4 w3-light-grey w3-text-black w3-margin" style="margin:0 auto; width: 45%;">
<div class="w4-row w3-section" style="margin:0 auto; width: 80%; text-align: left">
<h2 style="display: inline-block;">Hello "Customer"!</h2>
<button class="w3-button w3-right w3-section w3-green w3-ripple"> Logout </button>
</div>
<br>
<div class="w4-row w3-section">
<h2 class="w3-row">What are you looking for?</h2>
<div class="w3-rest" style="width:500px">
<input class="w3-input w3-border" name="query" type="text" placeholder="Name of a Drug">
<button class="w3-button w3-section w3-blue w3-ripple"> Go </button>
</div>
</div>
</div>
</center>
</body>
</html>