Guest User

Untitled

a guest
Jan 29th, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.88 KB | None | 0 0
  1. <?php
  2. include('adminLoginProcess.php'); // Includes Login Script
  3. if($_SESSION['admin'] == FALSE){
  4. header("location: adminLogin.php");
  5. }
  6. if($_SESSION['admin'] == TRUE)
  7. ?>
  8.  
  9. <?php
  10. require "connect.php";
  11. session_start(); // Starting Session
  12. $error=''; // Variable To Store Error Message
  13. if (isset($_POST['admin_submit'])) {
  14. if (empty($_POST['admin_username']) || empty($_POST['admin_password'])) {
  15. $error = "Username or Password is invalid";
  16. }
  17. else
  18. {
  19. // Define $username and $password
  20. $admin_username=$_POST['admin_username'];
  21. $admin_password=$_POST['admin_password'];
  22. // Establishing Connection with Server by passing server_name, user_id and password as a parameter
  23. // To protect MySQL injection for Security purpose
  24. $admin_username = stripslashes($admin_username);
  25. $admin_password = stripslashes($admin_password);
  26. $admin_username = mysqli_real_escape_string($con,$admin_username);
  27. $admin_password = mysqli_real_escape_string($con,$admin_password);
  28. // Selecting Database
  29. // SQL query to fetch information of registerd users and finds user match.
  30. $query = mysqli_query($con,"select * from admin_tbl where admin_password='$admin_password' AND admin_username='$admin_username'");
  31. $rows = mysqli_num_rows($query);
  32. if ($rows == 1) {
  33. $_SESSION['admin_user']=$admin_username; // Initializing Session
  34. $_SESSION['admin'] = TRUE;
  35. $_SESSION['admin_id'] = $row['admin_id'];;
  36. $usernameagain = $_SESSION['admin_user'];
  37. $adminId = $_SESSION['admin_id'];
  38. header("location: index.php"); // Redirecting To Other Page
  39. } else {
  40. $error = "Username or Password is invalid";
  41. }
  42. mysqli_close($con); // Closing Connection
  43. }
  44. }
  45. ?>
  46.  
  47. <?php
  48. include('adminLoginProcess.php'); // Includes Login Script
  49.  
  50. if(isset($_SESSION['admin_user'])){
  51. header("location: index.php");
  52. }
  53. ?>
  54. <html>
  55. <title>Her Voice | Admin Login Page</title>
  56. <head>
  57. <script src="js/jquery.js"></script>
  58. <script src="js/bootstrap.js"></script>
  59. <link rel="stylesheet" href="css/bootstrap.css">
  60. <link rel="shortcut icon" href="images/marketechlogo.ico" />
  61. </head>
  62. <body>
  63. <div class = "container">
  64. <br><br><br>
  65. <div class = "col-md-2 col-md-offset-5">
  66. <form method = "POST" action = "" > <!-- Admin Login Form -->
  67. <table class = "table table-responsive">
  68. <tr>
  69. <th class = "col-md-12"><a href ="#username"><font color = "black"><center>Username:</center></font></th>
  70. </tr>
  71. <tr>
  72. <td class = "col-md-12"><center><input type = "text" id = "username" name = "admin_username"></center></td>
  73. </tr>
  74. </table>
  75. <table class = "table table-responsive">
  76. <tr>
  77. <th class = "col-md-12"><a href ="#password"><font color = "black"><center>Password:</center></font></th>
  78. </tr>
  79. <tr>
  80. <td class = "col-md-12"><center><input type = "password" id = "password" name = "admin_password"></center></td>
  81. </tr>
  82. </table>
  83. <table class = "table table-responsive">
  84. <tr>
  85. <th class = "col-md-12"><center><input type = "submit" class = "btn btn-lg btn-default" name="admin_submit" value = "Log In"></form></center></th>
  86. </tr>
  87. </table>
  88. </div>
  89. </div>
  90. </form>
  91. </body>
  92. </html>
  93.  
  94. <?php
  95.  
  96. $host = "localhost";
  97. $user = "id883133_hervoice";
  98. $pass = "root031098";
  99. $db = "id883133_hv_db";
  100.  
  101. $con = mysqli_connect($host,$user,$pass,$db);
  102. if(!$con){
  103. //echo "Connection Error".mysqli_connect_error();
  104. }else{
  105. //echo "<h3>Connected</h3>";
  106. }
  107.  
  108. ?>
Add Comment
Please, Sign In to add comment