Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- include('adminLoginProcess.php'); // Includes Login Script
- if($_SESSION['admin'] == FALSE){
- header("location: adminLogin.php");
- }
- if($_SESSION['admin'] == TRUE)
- ?>
- <?php
- require "connect.php";
- session_start(); // Starting Session
- $error=''; // Variable To Store Error Message
- if (isset($_POST['admin_submit'])) {
- if (empty($_POST['admin_username']) || empty($_POST['admin_password'])) {
- $error = "Username or Password is invalid";
- }
- else
- {
- // Define $username and $password
- $admin_username=$_POST['admin_username'];
- $admin_password=$_POST['admin_password'];
- // Establishing Connection with Server by passing server_name, user_id and password as a parameter
- // To protect MySQL injection for Security purpose
- $admin_username = stripslashes($admin_username);
- $admin_password = stripslashes($admin_password);
- $admin_username = mysqli_real_escape_string($con,$admin_username);
- $admin_password = mysqli_real_escape_string($con,$admin_password);
- // Selecting Database
- // SQL query to fetch information of registerd users and finds user match.
- $query = mysqli_query($con,"select * from admin_tbl where admin_password='$admin_password' AND admin_username='$admin_username'");
- $rows = mysqli_num_rows($query);
- if ($rows == 1) {
- $_SESSION['admin_user']=$admin_username; // Initializing Session
- $_SESSION['admin'] = TRUE;
- $_SESSION['admin_id'] = $row['admin_id'];;
- $usernameagain = $_SESSION['admin_user'];
- $adminId = $_SESSION['admin_id'];
- header("location: index.php"); // Redirecting To Other Page
- } else {
- $error = "Username or Password is invalid";
- }
- mysqli_close($con); // Closing Connection
- }
- }
- ?>
- <?php
- include('adminLoginProcess.php'); // Includes Login Script
- if(isset($_SESSION['admin_user'])){
- header("location: index.php");
- }
- ?>
- <html>
- <title>Her Voice | Admin Login Page</title>
- <head>
- <script src="js/jquery.js"></script>
- <script src="js/bootstrap.js"></script>
- <link rel="stylesheet" href="css/bootstrap.css">
- <link rel="shortcut icon" href="images/marketechlogo.ico" />
- </head>
- <body>
- <div class = "container">
- <br><br><br>
- <div class = "col-md-2 col-md-offset-5">
- <form method = "POST" action = "" > <!-- Admin Login Form -->
- <table class = "table table-responsive">
- <tr>
- <th class = "col-md-12"><a href ="#username"><font color = "black"><center>Username:</center></font></th>
- </tr>
- <tr>
- <td class = "col-md-12"><center><input type = "text" id = "username" name = "admin_username"></center></td>
- </tr>
- </table>
- <table class = "table table-responsive">
- <tr>
- <th class = "col-md-12"><a href ="#password"><font color = "black"><center>Password:</center></font></th>
- </tr>
- <tr>
- <td class = "col-md-12"><center><input type = "password" id = "password" name = "admin_password"></center></td>
- </tr>
- </table>
- <table class = "table table-responsive">
- <tr>
- <th class = "col-md-12"><center><input type = "submit" class = "btn btn-lg btn-default" name="admin_submit" value = "Log In"></form></center></th>
- </tr>
- </table>
- </div>
- </div>
- </form>
- </body>
- </html>
- <?php
- $host = "localhost";
- $user = "id883133_hervoice";
- $pass = "root031098";
- $db = "id883133_hv_db";
- $con = mysqli_connect($host,$user,$pass,$db);
- if(!$con){
- //echo "Connection Error".mysqli_connect_error();
- }else{
- //echo "<h3>Connected</h3>";
- }
- ?>
Add Comment
Please, Sign In to add comment