Login System Using PHP and JavaScript
Hello, I am trying to create a login system for my website, however I am confused as how to implement a PHP code that will make my login system work. I have tried using codes from various YouTube tutorials; however, people have said that some codes don't work because they have a newer version of XAMPP. I am using XAMPP version 3.2.2 and have seen that in many tutorials, people use MySQL and/or Apache. Could you please provide a PHP code in which if a username or password is wrong, an alert will pop-up saying, "Incorrect username or password." and if a username and password is correct, the user will be directed to another web page?
Here is my code:
<!doctype html>
<html lang="en">
<head>
<title>Business Department</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<style>
.navbar {
margin-bottom: 0;
border-radius: 0;
/* background-color; he put it purple make it stay gray or change to dark gray */
color: #474747; /* text color */
padding: 1% 0;
font-size: 1.2em; /* This increases text font */
border: 0; /* the black thing */
}
.navbar-brand {
float: left;
min-height: 55px;
padding: 0 15px 5px;
}
.navbar-inverse .navbar-nav .active a, .navbar-inverse .navbar-nav .active a:focus, .navbar-inverse .navbar-nav .active a:hover {
color: #FFF;
background-color: #222222; /* for the black thing in home */ /* #232323 try to change later on if it does not match with anything else */
}
.navbar-inverse .navbar-nav li a { color: #D5D5D5; /* text color?? */ }
.btn { /* LOGIN button */
font-size: 18px;
color: #FFF;
padding: 12px 22px;
background: #000000;
border: 2px solid #FFF;
}
#icon {
max-width: 200px; /* to change the size of 3 images */
margin: 1% auto;
margin-top: 30px;
margin-bottom: 26px;
}
footer {
width: 100%;
background-color: #222;
padding: 5%;
color: #FFF;
}
.fa {
padding: 15px; /* social media pics size */
font-size: 25px;
color: #FFF;
}
.fa:hover {
color: #D5D5D5;
text-decoration: none;
}
@media (max-width: 900px) {
.fa {
font-size: 20px;
padding: 10px;
}
}
@media (max-width: 600px) { /* this is to not show the getting started buttons and header on mobile */
#icon { max-width: 150px; }
h2 { /* h4 size in mobile */ font-size: 1.7em; }
}
body {
height: 100%;
/**FULL SCREEN BACKGROUND IMAGE**/
background: url('img/hallway2.jpg') no-repeat center center fixed;
background-size: cover;
}
.center-block { float: none; }
form {
margin: 15% auto 15% auto;
padding: 5%;
background: rgba(0,0,0,0.7);
color: #FFF;
}
</style>
</head>
<body>
<!--TOP NAVIGATION-->
<nav class="navbar navbar-inverse">
<div class="container-fluid">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#myNavbar"> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span> </button>
<!--BRAND-->
<a class="navbar-brand" href="indexReference.html"><img src="img/LogoTop.jpg"></a> </div>
<div class="collapse navbar-collapse" id="myNavbar">
<ul class="nav navbar-nav navbar-right">
<li class="active"><a href="index.html">Home</a></li>
<li><a href="about.html">About</a></li>
<li><a href="courses.html">Courses</a></li>
<li><a href="deca.html">DECA</a></li>
<li><a href="schoolstore.html">School Store</a></li>
<li><a href="resources.html">Resources</a></li>
<li><a href="contacts.html">Contacts</a></li>
</ul>
</div>
</div>
</nav>
<!--LOGIN FORM-->
<div class="container">
<div class="row">
<div class="col-sm-6 center-block">
<form action="YOUR_LOGIN_SCRIPT.php">
<h3 class="text-center"><img class="img-circle" src="https://placeimg.com/75/75/tech" alt="logo"> Log-In</h3>
<div class="form-group">
<label for="Email">Email address</label>
<input type="email" class="form-control" id="Email" placeholder="you@domain.com">
</div>
<div class="form-group">
<label for="Password">Password:</label>
<input type="password" class="form-control" id="Password" placeholder="8 characters">
</div>
<button type="submit" class="center-block btn btn-lg btn-primary">Log-in</button>
</form>
</div>
</div>
</div>
<!-- footer -->
<footer class="container-fluid text-center">
<div class="row">
<div class="col-sm-4">
<h3><b>Contact Us</b></h3>
<br style="line-height: 10%">
<h4 style="line-height: 90%">Address: xx<h4>
<h4 style="line-height: 90%">Phone:xx<h4>
<h4 style="line-height: 90%">Fax: xxx<h4>
<h4 style="line-height: 90%">Email: xxxx.com</h4>
</div>
<!-- For social media pics -->
<div class="col-sm-4">
<h3><b>Stay Connected</b></h3>
<a href="x" class="fa fa-facebook"></a>
<a href="x" class="fa fa-twitter"></a>
<a href="x" class="fa fa-instagram"></a>
<a href="x" class="fa fa-youtube"></a>
<h3 style="line-height: 90%">©2018 x</h3>
<h4>xxx</h4>
</div>
<div class="col-sm-4">
<a href="https://xx.aspx">
<img src="img/xxx.jpg" class="icon">
</a>
</div>
</div>
</footer>
</body>
</html>
