Step 1 Creation of Login page Module
This is how Our Landing page will look like:
Functionalities of this page:
- You Can show some important details on the landing page.
- Existing Users will be able to login through user login page.
- Admins can also login using admin login form.
- Users will be able to signup using above signup button.
- These will be our main functionalities of login page.
Code:
Below is the Code for creating above page:
<?php
session_start();
?>
<!DOCTYPE html>
<html>
<head>
<title>Library Management System</title>
<meta charset="utf-8" name="viewport" content="width=device-width,intial-scale=1">
<link rel="stylesheet" type="text/css" href="bootstrap-4.4.1/css/bootstrap.min.css">
<script type="text/javascript" src="bootstrap-4.4.1/js/juqery_latest.js"></script>
<script type="text/javascript" src="bootstrap-4.4.1/js/bootstrap.min.js"></script>
</head>
<style type="text/css">
#main_content{
background: rgba(245, 245, 245, 0.9);
padding: 50px;
}
#side_bar{
background: rgba(245, 245, 245, 0.9);
padding: 50px;
}
body{
background: rgba(245, 245, 245, 0.4);
background-image: url("https://img.freepik.com/free-photo/abundant-collection-antique-books-wooden-shelves-generated-by-ai_188544-29660.jpg?size=626&ext=jpg&ga=GA1.1.1546980028.1704240000&semt=sph");
}
</style>
<body>
<nav class="navbar navbar-expand-lg navbar-dark bg-dark">
<div class="container-fluid">
<div class="navbar-header">
<a class="navbar-brand" href="index.php">Library Management System</a>
</div>
<ul class="nav navbar-nav navbar-right">
<li class="nav-item">
<a class="nav-link" href="index.php">User Login</a>
</li>
<li class="nav-item">
<a class="nav-link" href="admin/indexad.php">Admin Login</a>
</li>
<li class="nav-item">
<a class="nav-link" href="signup.php"></span>Signup</a>
</li>
</ul>
</div>
</nav>
<div class="row">
<div class="col-md-4" id="side_bar">
<h5>Today's Quote</h5>
<h6>“There is more treasure in books than in all the pirate's loot on Treasure Island"</h6>
<p>~ Walt Disney</p>
<h5>Library Timing</h5>
<ul>
<li>Opening: 9:00 AM</li>
<li>Closing: 12:00 PM</li>
</ul>
<h5>What We provide ?</h5>
<ul>
<li>AC Rooms</li>
<li>Free Wi-fi</li>
<li>Learning Environment</li>
<li>Discussion Room</li>
<li>Free Electricity</li>
</ul>
</div>
<div class="col-md-8" id="main_content">
<center><h3>User Login Form</h3></center>
<form action="" method="post">
<div class="form-group">
<label for="email">Email ID:</label>
<input type="text" name="email" class="form-control" required>
</div>
<div class="form-group">
<label for="password">Password:</label>
<input type="password" name="password" class="form-control" required>
</div>
<button type="submit" name="login" class="btn btn-primary">Login</button> |
<a href="signup.php"> Signup now !!</a>
</form>
<?php
if(isset($_POST['login'])){
$connection = mysqli_connect("localhost","root","");
$db = mysqli_select_db($connection,"lms");
$query = "select * from users where email = '$_POST[email]'";
$query_run = mysqli_query($connection,$query);
while ($row = mysqli_fetch_assoc($query_run)) {
if($row['email'] == $_POST['email']){
if($row['password'] == $_POST['password']){
$_SESSION['name'] = $row['name'];
$_SESSION['email'] = $row['email'];
$_SESSION['id'] = $row['id'];
header("Location: user_dashboard.php");
}
else{
?>
<br><br><center><span class="alert-danger">Wrong Password !!</span></center>
<?php
}
}
}
}
?>
</div>
</div>
</body>
</html>
<?php
session_start();
?>
<!DOCTYPE html>
<html>
<head>
<title>LMS | Login</title>
<meta charset="utf-8" name="viewport" content="width=device-width,intial-scale=1">
<link rel="stylesheet" type="text/css" href="../bootstrap-4.4.1/css/bootstrap.min.css">
<script type="text/javascript" src="./bootstrap-4.4.1/js/juqery_latest.js"></script>
<script type="text/javascript" src="./bootstrap-4.4.1/js/bootstrap.min.js"></script>
</head>
<style type="text/css">
#main_content{
background: rgba(245, 245, 245, 0.9);
padding: 50px;
}
#side_bar{
background: rgba(245, 245, 245, 0.9);
padding: 50px;
}
body{
background: rgba(245, 245, 245, 0.4);
background-image: url("https://img.freepik.com/free-photo/abundant-collection-antique-books-wooden-shelves-generated-by-ai_188544-29660.jpg?size=626&ext=jpg&ga=GA1.1.1546980028.1704240000&semt=sph");
}
</style>
<body>
<nav class="navbar navbar-expand-lg navbar-dark bg-dark">
<div class="container-fluid">
<div class="navbar-header">
<a class="navbar-brand" href="index.php">Library Management System</a>
</div>
<ul class="nav navbar-nav navbar-right">
<li class="nav-item">
<a class="nav-link" href="./index.php">User Login</a>
</li>
<li class="nav-item">
<a class="nav-link" href="./admin_login.php">Admin Login</a>
</li>
<li class="nav-item">
<a class="nav-link" href="../signup.php"></span>Signup</a>
</li>
</ul>
</div>
</nav>
<div class="row">
<div class="col-md-4" id="side_bar">
<h5>Today's Quote</h5>
<h6>“There is more treasure in books than in all the pirate's loot on Treasure Island"</h6>
<p>~ Walt Disney</p>
<h5>Library Timing</h5>
<ul>
<li>Opening: 9:00 AM</li>
<li>Closing: 12:00 PM</li>
</ul>
<h5>What We provide ?</h5>
<ul>
<li>AC Rooms</li>
<li>Free Wi-fi</li>
<li>Learning Environment</li>
<li>Discussion Room</li>
<li>Free Electricity</li>
</ul>
</div>
<div class="col-md-8" id="main_content">
<center><h3><u>Admin Login Form</u></h3></center>
<form action="" method="post">
<div class="form-group">
<label for="email">Email ID:</label>
<input type="text" name="email" class="form-control" required>
</div>
<div class="form-group">
<label for="password">Password:</label>
<input type="password" name="password" class="form-control" required>
</div>
<button type="submit" name="login" class="btn btn-primary">Login</button>
</form>
<?php
if(isset($_POST['login'])){
$connection = mysqli_connect("localhost","root","");
$db = mysqli_select_db($connection,"lms");
$query = "select * from admins where email = '$_POST[email]'";
$query_run = mysqli_query($connection,$query);
while ($row = mysqli_fetch_assoc($query_run)) {
if($row['email'] == $_POST['email']){
if($row['password'] == $_POST['password']){
$_SESSION['name'] = $row['name'];
$_SESSION['email'] = $row['email'];
header("Location: admin_dashboard.php");
}
else{
?>
<br><br><center><span class="alert-danger">Wrong Password !!</span></center>
<?php
}
}
}
}
?>
</div>
</div>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<title>LMS</title>
<meta charset="utf-8" name="viewport" content="width=device-width,intial-scale=1">
<link rel="stylesheet" type="text/css" href="bootstrap-4.4.1/css/bootstrap.min.css">
<script type="text/javascript" src="bootstrap-4.4.1/js/juqery_latest.js"></script>
<script type="text/javascript" src="bootstrap-4.4.1/js/bootstrap.min.js"></script>
</head>
<style type="text/css">
#main_content{
background: rgba(245, 245, 245, 0.9);
padding: 50px;
}
#side_bar{
background: rgba(245, 245, 245, 0.9);
padding: 50px;
}
body{
background: rgba(245, 245, 245, 0.4);
background-image: url("https://img.freepik.com/free-photo/abundant-collection-antique-books-wooden-shelves-generated-by-ai_188544-29660.jpg?size=626&ext=jpg&ga=GA1.1.1546980028.1704240000&semt=sph");
}
</style>
<body>
<nav class="navbar navbar-expand-lg navbar-dark bg-dark">
<div class="container-fluid">
<div class="navbar-header">
<a class="navbar-brand" href="index.php">Library Management System</a>
</div>
<ul class="nav navbar-nav navbar-right">
<li class="nav-item">
<a class="nav-link" href="index.php">User Login</a>
</li>
<li class="nav-item">
<a class="nav-link" href="admin/indexad.php">Admin Login</a>
</li>
<li class="nav-item">
<a class="nav-link" href="signup.php"></span>Signup</a>
</li>
</ul>
</div>
</nav>
<div class="row">
<div class="col-md-4" id="side_bar">
<h5>Today's Quote</h5>
<h6>“There is more treasure in books than in all the pirate's loot on Treasure Island"</h6>
<p>~ Walt Disney</p>
<h5>Library Timing</h5>
<ul>
<li>Opening: 9:00 AM</li>
<li>Closing: 12:00 PM</li>
</ul>
<h5>What We provide ?</h5>
<ul>
<li>AC Rooms</li>
<li>Free Wi-fi</li>
<li>Learning Environment</li>
<li>Discussion Room</li>
<li>Free Electricity</li>
</ul>
</div>
<div class="col-md-8" id="main_content">
<center><h3><u>User Registration Form</u></h3></center>
<form action="register.php" method="post">
<div class="form-group">
<label for="name">Full Name:</label>
<input type="text" name="name" class="form-control" required>
</div>
<div class="form-group">
<label for="email">Email ID:</label>
<input type="text" name="email" class="form-control" required>
</div>
<div class="form-group">
<label for="password">Password:</label>
<input type="password" name="password" class="form-control" required>
</div>
<div class="form-group">
<label for="mobile">Mobile:</label>
<input type="text" name="mobile" class="form-control" required>
</div>
<div class="form-group">
<label for="address">Address:</label>
<textarea name="address" class="form-control" required></textarea>
</div>
<button type="submit" class="btn btn-primary">Register</button>
</form>
</div>
</div>
</body>
</html>
<?php
$connection = mysqli_connect("localhost","root","");
$db = mysqli_select_db($connection,"lms");
$query = "insert into users values('','$_POST[name]','$_POST[email]','$_POST[password]',$_POST[mobile],'$_POST[address]')";
$query_run = mysqli_query($connection,$query);
?>
<script type="text/javascript">
alert("Registration successfull...You may Login now !!");
window.location.href = "index.php";
</script>
<?php
session_unset();
session_destroy();
header("Location: index.php");
?>
If you are a new user you can signup and then use login for user dashboard.
Library Management System Project | Software Development
Library Management System is one of the most common software development projects till date. In this article, we are going to make the Library Management System software development project, from scratch, for final year students. We will be covering all the steps you have to do while developing this project.