-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathd1.php
More file actions
154 lines (147 loc) · 3.72 KB
/
d1.php
File metadata and controls
154 lines (147 loc) · 3.72 KB
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
<html>
<head>
<?php include "header.php"; ?>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js"></script>
</head>
<style>
.error
{
color: #FF0000;
}
<style>
.content
{
margin: 5px;
padding : 4rem -5rem 4rem 3rem;
box-shadow:0 0 5px 10px rgba(0,0,0, .05);
}
.form-control
{
display: block;
width:300px;
font-size:1rem;
font-weight:400;
line-height:1.5;
border-color:#00ac96;
border-style:solid;
border-width:0 0 1px 0;
padding : 0;
color:#495057;
height:auto;
border-radius:0;
background-color: #fff;
background-clip: padding-box;
}
</style>
<body>
<?php include "nav1.php";
$emailid = $password = "";
$emailErr = $passErr = "";
function test_input($data)
{
$data = trim($data); //remove space
$data = stripslashes($data); //removes backslashes
$data = htmlspecialchars($data); //remove special characters
return $data;
}
if ($_SERVER["REQUEST_METHOD"] == "POST")
{
if (empty($_POST["emailid"]))
{
$emailErr = "Email is required";
}
else
{
$emailid = test_input($_POST["emailid"]);
if (!filter_var($emailid,FILTER_VALIDATE_EMAIL))
{
$emailErr = "Invalid email format";
}
}
if (empty($_POST["pwd"]))
{
$passErr = "Password is required";
}
else
{
$password=test_input($_POST["pwd"]);
}
}
?>
<div class="container" style = "margin-top : 100px">
<div class ="row content">
<div class ="col-md-6 mb-3">
<img src = "myimages2/login1.webp" width="500" height="350" style="margin-top:30px">
</div>
<div clas="col-md-6">
<h2 class="signin-text mb-3" style = "font-family : 'Monotype Corsiva' ; color:#E6120E">User Login</h2>
<form method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>">
<div class="form-group">
<label><b>Email ID</b></label><span class="error">* <?php echo $emailErr;?></span>
<input type = text name="emailid" class="form-control" placeholder="Enter Your Email ID" value="<?php echo $emailid;?>">
</div>
<div class="form-group">
<label><b>Password</b></label><span class="error">* <?php echo $passErr;?></span>
<input type = password name="pwd" class="form-control" placeholder="Enter Your Password" value="<?php echo $password?>">
</div>
<br>
<div class="form-group">
<input type = checkbox name="rem"><b>Remember Me</b>
<br>
<input type = submit name = submit value="Login" class="btn btn-primary">
<a href = "registration.php" class="btn btn-primary">SignUp</a>
</div>
</form>
</div>
</div>
</div>
</body>
</html>
<?php
session_start();
include "dbconfigure.php";
if($emailErr=="" && $passErr=="")
{
if(isset($_POST['submit']))
{
$emailid = $_POST['emailid'];
$password = $_POST['pwd'];
if(isset($_POST['rem']))
{
$remember = "yes";
}
else
{
$remember = "no";
}
$query = "select count(*) from siteuser where emailid='$emailid' and pwd='$password'";
$ans = my_one($query);
if($ans==1)
{
$_SESSION['semail'] = $emailid;
$_SESSION['spwd'] = $password;
if($remember=='yes')
{
setcookie('cemail',$emailid,time()+60*60*24*7);
setcookie('cpwd',$password,time()+60*60*24*7);
}
if(isset($_GET['id']))
{
header("location:booking.php?id=".$_GET['id']);
}
else
{
header("location:userhome.php");
}
}
else{
echo '<script>alert("Invalid Login credentials,Try Again")</script>';
}
}
}
?>