/
login.php
97 lines (81 loc) · 2.59 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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title></title>
<script>
<!--
var ScrollMsg= "Payroll and Management System - "
var CharacterPosition=0;
function StartScrolling() {
document.title=ScrollMsg.substring(CharacterPosition,ScrollMsg.length)+
ScrollMsg.substring(0, CharacterPosition);
CharacterPosition++;
if(CharacterPosition > ScrollMsg.length) CharacterPosition=0;
window.setTimeout("StartScrolling()",150); }
StartScrolling();
// -->
</script>
<link href="assets/must.png" rel="shortcut icon">
<link rel="stylesheet" href="assets/css/login.css">
</head>
<body class="hold-transition login-page">
<?php
require('db.php');
session_start();
// If form submitted, insert values into the database.
if (isset($_POST['username']))
{
$username = $_POST['username'];
$password = $_POST['password'];
$username = stripslashes($username);
$username = mysql_real_escape_string($username);
$password = stripslashes($password);
$password = mysql_real_escape_string($password);
//Checking is user existing in the database or not
$query = "SELECT * FROM `user` WHERE username='$username' and password='$password'";
$result = mysql_query($query) or die(mysql_error());
$rows = mysql_num_rows($result);
if($rows==1)
{
$_SESSION['username'] = $username;
header("Location: index.php");
}
else
{
?>
<script>
alert('Invalid Keyword, please try again.');
window.location.href='login.php';
</script>
<?php
}
}
else
{
?>
<br><br><br><br><br><br><br><br>
<div class="container">
<section id="content">
<form action="" method="post">
<h1>Login Form</h1>
<div>
<input name=username type="text" placeholder="Enter Username" required>
<!-- <input type="text" placeholder="Username" required="" id="username" /> -->
</div>
<div>
<input name=password type="password" placeholder="Enter Password" required>
<!-- <input type="password" placeholder="Password" required="" id="password" /> -->
</div>
<div>
<input type="submit" value="Log in" />
<!-- <a href="index.php">Back to Home</a> -->
<!-- <a href="">Forgot password?</a> -->
</div>
</form><!-- form -->
</section><!-- content -->
</div><!-- container -->
<?php } ?>
</body>
</html>