-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsign_in.php
159 lines (130 loc) · 4.63 KB
/
sign_in.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
152
153
154
155
156
157
158
159
<?php
$servername = "localhost"; //Name of the server where database resides, ex: 127.0.0.1
$port_no = 3306; // Port number for Windows
$username = "user";
$password = "";
$myDB= "project"; //Name of the database to access
try {$conn = new PDO("mysql:host=$servername; port= $port_no, dbname=$myDB", $username, $password); //set the PDO error mode to exception
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); }
catch(PDOException $e){echo "Connection failed: " . $e->getMessage();}
?>
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
<title>SignIn</title>
</head>
<body>
<section class="vh-100">
<div class="container py-5 h-100">
<div class="row d-flex align-items-center justify-content-center h-100">
<div class="col-md-8 col-lg-7 col-xl-6">
<img src="https://mdbootstrap.com/img/Photos/new-templates/bootstrap-login-form/draw2.svg" class="img-fluid" alt="Phone image">
</div>
<div class="col-md-7 col-lg-5 col-xl-5 offset-xl-1">
<form method="post" action="signin.php" >
<!-- Email input -->
<div class="form-outline mb-4">
<input type="email" id="form1Example13" class="form-control form-control-lg" , name = "email" />
<label class="form-label" for="form1Example13">Email address</label>
</div>
<!-- Password input -->
<div class="form-outline mb-4">
<input type="password" id="form1Example23" class="form-control form-control-lg" , name = "pass" />
<label class="form-label" for="form1Example23">Password</label>
</div>
<div class='mb-3'>
<select class="form-select mb-5" name="userType">
<option value="buyer" selected>buyer</option>
<option value="seller">seller</option>
</select>
<input type="submit" class="btn btn-primary btn-lg btn-block" name="submit" value="Log in">
<a href="signup.php" class="btn btn-primary btn-lg btn-block" >Sign Up</a>
<a href="home.php" class="btn btn-primary btn-lg btn-block" >Home</a>
</div>
</form>
</div>
</div>
</div>
</section>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-ka7Sk0Gln4gmtz2MlQnikT1wXgYsOg+OMhuP+IlRH9sENBO0LRn5q+8nbTov4+1p" crossorigin="anonymous"></script>
</body>
</html>
<?php
if(isset($_POST['submit']))
{
if($_POST['userType']==='buyer')
{
$email = $_POST['email'];
$count = $conn->query("Select a.* from project.buyer a where a.buyerid = \"$email\"");
$pass = "";
while ($row=$count->fetch(PDO::FETCH_ASSOC)) {
foreach($row as $k => $val)
{
if($k=="pass")
$pass = $val;
}
}
if($pass=="")
{
echo "<script>alert('Invalid User ID ')</script>";
}
else if($pass!=$_POST['pass'])
{
echo "<script>alert('Invalid password ')</script>";
}
else
{
$cookie_name = "userName";
$cookie_value = $_POST["email"];
setcookie($cookie_name, $cookie_value);
header("Location:home.php");
exit;
}
}
else {
$email = $_POST['email'];
$count = $conn->query("Select a.* from project.seller a where a.sellerid = \"$email\"");
$pass = "";
while ($row=$count->fetch(PDO::FETCH_ASSOC)) {
foreach($row as $k => $val)
{
if($k=="pass")
$pass = $val;
}
}
if($pass=="")
{
echo "<script>alert('Invalid User ID ')</script>";
}
else if($pass!=$_POST['pass'])
{
echo "<script>alert('Invalid password ')</script>";
}
else
{
$cookie_name = "userName";
$cookie_value = $_POST["email"];
setcookie($cookie_name, $cookie_value);
header("Location:seller.php");
exit;
}
}
}
?>
Footer
© 2022 GitHub, Inc.
Footer navigation
Terms
Privacy
Security
Status
Docs
Contact GitHub
Pricing
API
Training
Blog
About