-
Notifications
You must be signed in to change notification settings - Fork 0
/
login.php
135 lines (100 loc) · 2.9 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
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
<!--
//login.php
project
!-->
<?php
include('database_connection.php');
if (session_status() == PHP_SESSION_NONE) {
session_start();
}
$message = '';
if(isset($_SESSION['username']))
{
header('location:index.php');
}
if(isset($_POST['signup'])){
header('location:signup.php');
}
if (isset($_POST['login']) && $_POST['username']=='' && $_POST['password']==''){
$message = '<label>Fields Empty</label>';
}
if(isset($_POST['login']) && $_POST['username']!='' && $_POST['password']!='')
{
$sql = "SELECT * FROM logindetails WHERE username ='".$_POST['username']."'";
$result = mysqli_query($conn,$sql);
$count = $result->num_rows;
if($count > 0)
{
while($row = mysqli_fetch_array($result)) {
if(MD5($_POST["password"])== $row["password"])
{
$_SESSION['username'] = $row['username'];
echo $_SESSION['username'];
echo "yolo";
header('location:index.php');
}
else
{
$message = '<label>Wrong Password</label>';
}
}
}
else
{
$message = '<label>Wrong Username</label>';
}
}
?>
<html>
<head>
<title>Chat Application using PHP Ajax Jquery</title>
<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<style type="text/css">
.imgcontainer {
text-align: center;
margin: 24px 0 12px 0;
}
img.avatar {
width: 12%;
border-radius: 50%;
}
.container {
width: 50%;
padding: 16px;
}
</style>
</head>
<body>
<div class="container">
<br />
<br />
<div class="panel panel-default">
<div class="panel-heading" align="center">Web Chat Application</div>
<div class="panel-body">
<p class="text-danger"><?php echo $message; ?></p>
<form method="post">
<div class="imgcontainer">
<img src="avatar.png" alt="Avatar" class="avatar">
</div>
<div class="form-group">
<label>Enter Username</label>
<input type="text" name="username" class="form-control" placeholder="Enter Username" />
</div>
<div class="form-group">
<label>Enter Password</label>
<input type="password" name="password" class="form-control" placeholder="Enter Password" />
</div>
<div class="form-group">
<input type="submit" name="login" class="btn btn-info" value="Login" />
<input type="submit" name="signup" class="btn btn-info" value="SignUp" />
</div>
</form>
</div>
</div>
</div>
</body>
</html>