Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- //Start the Session
- session_start();
- require('config.php');
- //3. If the form is submitted or not.
- //3.1 If the form is submitted
- if (isset($_POST['username']) and isset($_POST['password'])){
- //3.1.1 Assigning posted values to variables.
- $username = $_POST['username'];
- $password = $_POST['password'];
- //3.1.2 Checking the values are existing in the database or not
- $query = "SELECT * FROM `users` WHERE username='$username' and password='$password'";
- $result = mysqli_query($connection, $query) or die(mysqli_error($connection));
- $count = mysqli_num_rows($result);
- //3.1.2 If the posted values are equal to the database values, then session will be created for the user.
- if ($count == 1){
- $_SESSION['username'] = $username;
- }else{
- //3.1.3 If the login credentials doesn't match, he will be shown with an error message.
- $fmsg = "Invalid Login Credentials.";
- }
- }
- //3.1.4 if the user is logged in Greets the user with message
- if (isset($_SESSION['username'])){
- $username = $_SESSION['username'];
- header('Location: admincp.html'); // Redirecting To Home Page
- }
- //3.2 When the user visits the page first time, simple login form will be displayed.
- ?>
- <html>
- <head>
- <title> GijoeTeam LoginPanel</title>
- <link href="css/admincp.css" rel="stylesheet" type="text/css" media="screen">
- <script src="js/jquery.js" type="text/javascript"></script>
- <link rel="stylesheet" href="http://www.w3schools.com/lib/w3.css">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <style>
- .button {
- background-color: #4CAF50; /* Green */
- border: none;
- color: white;
- padding: 16px 32px;
- text-align: center;
- text-decoration: none;
- display: inline-block;
- font-size: 16px;
- margin: 4px 2px;
- -webkit-transition-duration: 0.4s; /* Safari */
- transition-duration: 0.4s;
- cursor: pointer;
- }
- .button1 {
- background-color: white;
- color: black;
- border: 2px solid #4CAF50;
- }
- .button1:hover {
- background-color: #4CAF50;
- color: white;
- }
- .button2 {
- background-color: white;
- color: black;
- border: 2px solid #008CBA;
- }
- .button2:hover {
- background-color: #008CBA;
- color: white;
- }
- .button3 {
- background-color: white;
- color: black;
- border: 2px solid #f44336;
- }
- .button3:hover {
- background-color: #f44336;
- color: white;
- }
- .button4 {
- background-color: white;
- color: black;
- border: 2px solid #e7e7e7;
- }
- .button4:hover {background-color: #e7e7e7;}
- .button5 {
- background-color: white;
- color: black;
- border: 2px solid #555555;
- }
- .button5:hover {
- background-color: #555555;
- color: white;
- }
- </style>
- </head>
- <body class="w3-container">
- <header class="w3-container w3-teal">
- <h1>Gijoe LoginPanel</h1>
- </header>
- <div id="loginp" class="cities">
- <p>
- <form action="login.php" method="post" enctype="multipart/form-data">
- <input type="text" id="username" name="username" placeholder="Username">
- <input type="password" id="password" name="password" placeholder="Password">
- <button type="submit" class="button button2">Login</button>
- </p>
- </form>
- </div>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement