-
Notifications
You must be signed in to change notification settings - Fork 36
/
login.php
106 lines (106 loc) · 3.03 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
<?php
session_start();
if (isset($_POST['submit']))
{
$conn = mysqli_connect("localhost","root","","railway");
if(!$conn){
echo "<script type='text/javascript'>alert('Database failed');</script>";
die('Could not connect: '.mysqli_connect_error());
}
$email=$_POST['email'];
$pw=$_POST['pw'];
$sql = "SELECT * FROM passengers WHERE email = '$email' AND password = '$pw';";
$sql_result = mysqli_query ($conn, $sql) or die ('request "Could not execute SQL query" '.$sql);
$user = mysqli_fetch_assoc($sql_result);
if(!empty($user)){
$_SESSION['user_info'] = $user['email'];
$message='Logged in successfully';
}
else{
$message = 'Wrong email or password.';
}
echo "<script type='text/javascript'>alert('$message');</script>";
}
?>
<!DOCTYPE html>
<html>
<head>
<title>Login</title>
</head>
<script type="text/javascript">
function validate() {
var EmailId=document.getElementById("email");
var atpos = EmailId.value.indexOf("@");
var dotpos = EmailId.value.lastIndexOf(".");
var pw=document.getElementById("pw");
if (atpos<1 || dotpos<atpos+2 || dotpos+2>=EmailId.value.length)
{
alert("Enter valid email-ID");
EmailId.focus();
return false;
}
if(pw.value.length< 8)
{
alert("Password consists of atleast 8 characters");
pw.focus();
return false;
}
return true;
}
</script>
<style type="text/css">
#loginarea{
background-color: white;
width: 30%;
margin: auto;
border-radius: 25px;
border: 2px solid blue;
margin-top: 100px;
background-color: rgba(0,0,0,0.2);
box-shadow: inset -2px -2px rgba(0,0,0,0.5);
padding: 40px;
font-family:sans-serif;
font-size: 20px;
color: white;
}
html {
background: url(img/bg4.jpg) no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
#submit {
border-radius: 5px;
background-color: rgba(0,0,0,0);
padding: 7px 7px 7px 7px;
box-shadow: inset -1px -1px rgba(0,0,0,0.5);
font-family:"Comic Sans MS", cursive, sans-serif;
font-size: 17px;
margin:auto;
margin-top: 20px;
display:block;
color: white;
}
#logintext {
text-align: center;
}
.data {
color: white;
}
</style>
<body>
<?php include("header.php") ?>
<div id="loginarea">
<form id="login" action="login.php" onsubmit="return validate()" method="post" name="login">
<div id="logintext">Login to Indian Railways!</div><br/><br/>
<table>
<tr><td><div class="data">Enter E-Mail ID:</div></td><td><input type="text" id="email" size="30" maxlength="30" name="email"/></td></tr>
<tr></tr><tr></tr><tr></tr><tr></tr><tr></tr><tr></tr><tr></tr><tr></tr><tr></tr><tr></tr><tr></tr><tr></tr>
<tr><td><div class="data">Enter Password:</div></td><td><input type="password" id="pw" size="30" maxlength="30" name="pw"/></td></tr>
<tr></tr><tr></tr><tr></tr><tr></tr><tr></tr><tr></tr><tr></tr><tr></tr><tr></tr><tr></tr><tr></tr><tr></tr>
</table>
<INPUT TYPE="Submit" value="Submit" name="submit" id="submit" class="button">
</form></div>
</body>
</html>