Login page can be created using php and allows user to feed in the credentials when loggin in into the system. it is composed of username or email input, password input, labels and button which executes the command. when user clickes the login button the system will check if username and password are correct.
<?php
session_start();
error_reporting(0);
include('includes/dbconnection.php');
if(isset($_POST['login']))
{
$emailcon=$_POST['emailcont'];
$password=md5($_POST['password']);
$query=mysqli_query($con,"select ID from tbluser where (Email='$emailcon' || MobileNumber='$emailcon') && Password='$password' ");
$ret=mysqli_fetch_array($query);
if($ret>0){
$_SESSION['uid']=$ret['ID'];
echo "<script type='text/javascript'>document.location ='dashboard.php'; </script>";
}
else{
echo "<script>alert('Invalid Details');</script>";
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<title>Sign In Page</title>
<link href="css/bootstrap.css" rel='stylesheet' type='text/css' />
<!-- Main CSS-->
<link href="css/main.css" rel="stylesheet" media="all">
</head>
<body>
<div class="page-wrapper bg-blue p-t-100 p-b-100 font-robo">
<div class="wrapper wrapper--w680">
<div class="card card-1">
<div class="card-heading"><div>
<div class="card-body">
<h2 class="title">Sign In Your Account</h2>
<p class="pb-3" style="color: blue;">Email(test@gmail.com), Password(1234)</p>
<form method="POST">
<div class="row">
<div class="form-control">
<input type="text" class="form-group" placeholder="Registered Email or Contact Number" required="true" name="emailcont">
</div>
</div>
<div class="row mt-4">
<div class="form-control">
<input type="password" class="form-group" placeholder="Password" name="password" required="true">
</div>
</div>
<div class="p-t-20">
<button class="btn btn--radius btn-primary" type="submit" name="login">Sign IN</button>
</div>
<br>
<a href="signup.php">Don't have an account ? CREATE AN ACCOUNT</a>
</form>
</div>
</div>
</div>
</div>
<!-- Jquery JS-->
<script src="js/jquery.min.js"></script>
<script src="js/bootstrap.min.js"></script>
</body>
</html>
signup.php.php
<?php
include('includes/dbconnection.php');
if(isset($_POST['submit']))
{
$fname=$_POST['fname'];
$contno=$_POST['contactno'];
$email=$_POST['email'];
$password=md5($_POST['password']);
$ret=mysqli_query($con, "select Email from tbluser where Email='$email' || MobileNumber='$contno'");
$result=mysqli_fetch_array($ret);
if($result>0){
echo "<script>alert('This email or Contact Number already associated with another account');</script>";
}
else{
$query=mysqli_query($con, "insert into tbluser(FullName, MobileNumber, Email, Password) value('$fname', '$contno', '$email', '$password' )");
if ($query) {
echo "<script>alert('You have successfully registered');</script>";
echo "<script>window.location.href ='signin.php'</script>";
}
else
{
echo "<script>alert('Something Went Wrong. Please try again');</script>";
echo "<script>window.location.href ='index.php'</script>";
}
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<title>Sign Up Page</title>
<link href="css/bootstrap.css" rel='stylesheet' type='text/css' />
<link href="css/main.css" rel="stylesheet" media="all">
</head>
<body>
<div class="page-wrapper bg-blue p-t-100 p-b-100 font-robo">
<div class="wrapper wrapper--w680">
<div class="card card-1">
<div class="card-heading"></div>
<div class="card-body">
<h2 class="title">Registration Form</h2>
<form method="POST">
<div class="row">
<div class="form-control mb-4">
<input class="form-group" type="text" placeholder="NAME" name="fname" required="true">
</div>
</div>
<div class="row ">
<div class="form-control mb-4">
<input class="form-group" type="text" placeholder="Mobile Number" name="contactno" required="true">
</div>
</div>
<div class="row">
<div class="form-control mb-4">
<input class="form-group" type="email" placeholder="Email Address" name="email" required="true">
</div>
</div>
<div class="row ">
<div class="form-control">
<input type="password" value="" class="form-group" name="password" required="true" placeholder="Password">
</div>
</div>
<div class="p-t-20">
<button class="btn btn--radius btn-primary" type="submit" name="submit">Submit</button>
</div>
<br>
<a href="index.php" style="color: blue">Already have an account? Signin</a>
</form>
</div>
</div>
</div>
</div>
<!-- Jquery JS-->
<script src="js/jquery.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<!-- Main JS-->
<script src="js/global.js"></script>
</body>
</html>
dashboard.php.php
<?php
session_start();
error_reporting(0);
include('includes/dbconnection.php');
if (strlen($_SESSION['uid']==0)) {
header('location:logout.php');
} else{
? >
<!DOCTYPE html>
<html lang="en">
<head>
<title>Welcome Page</title>
<link href="css/bootstrap.css" rel='stylesheet' type='text/css' />
<link href="css/main.css" rel="stylesheet" media="all">
</head>
<body>
<div class="page-wrapper bg-blue p-t-100 p-b-100 font-robo">
<div class="wrapper wrapper--w680">
<div class="card card-1">
<div class="card-body">
<div class=" d-flex flex-row align-items-center justify-content-between">
<div class="">
<a href="logout.php"><button type="button" class="btn btn-sm btn-primary"><i class="fas fa-plus"></i> Logout
</button></a>
</div>
</div>
<div> </div>
<div class="row ">
<table id="" class="table table-bordered">
<thead>
<tr>
<th class="text-center">No</th>
<th>Name</th>
<th>Mobile Number</th>
<th>Email</th>
<th>Reg Date</th>
</tr>
</thead>
<tbody>
<?php
$uid=$_SESSION['uid'];
$ret=mysqli_query($con,"select * from tbluser ");
$cnt=1;
while($row=mysqli_fetch_array($ret))
{
?>
<tr>
<td> <?php echo $cnt;?> </td>
<td> <?php echo $row['FullName'];?> </td>
<td>0 <?php echo $row['MobileNumber'];?></td>
<td> <?php echo $row['Email'];?> </td>
<td> <?php echo htmlentities(date("d-m-Y", strtotime($row['RegDate'])));?> </td>
</tr>
<?php $cnt=$cnt+1;
} ?>
</tbody>
</table>
</div>
</div>
</div>
</div>
<!-- Jquery JS-->
<script src="js/jquery.min.js"> </script>
<script src="js/bootstrap.min.js"></script>
<script src="js/global.js"> </script>
</body>
</html>
<?php
} ?>
Download