Guest User

login.php

a guest
Jul 13th, 2017
29
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.36 KB | None | 0 0
  1. <?php
  2. include("config.php");
  3. session_start();
  4.  
  5. if($_SERVER["REQUEST_METHOD"] == "POST") {
  6. // username and password sent from form
  7.  
  8. $myusername = mysqli_real_escape_string($db,$_POST['username']);
  9. $mypassword = mysqli_real_escape_string($db,$_POST['password']);
  10.  
  11. $sql = "SELECT id FROM admin WHERE username = '$myusername' and passcode = '$mypassword'";
  12. $result = mysqli_query($db,$sql);
  13. $row = mysqli_fetch_array($result,MYSQLI_ASSOC);
  14. $active = $row['active'];
  15.  
  16. $count = mysqli_num_rows($result);
  17.  
  18. // If result matched $myusername and $mypassword, table row must be 1 row
  19.  
  20. if($count == 1) {
  21. session_register("myusername");
  22. $_SESSION['login_user'] = $myusername;
  23.  
  24. header("location: welcome.php");
  25. }else {
  26. $error = "<center><b>Your login username or password is invalid, or you have not entered a password nor a username.</b></center>";
  27. }
  28. }
  29. ?>
  30. <html>
  31. <head>
  32. <title>OKRA Networks | Login</title>
  33.  
  34. <style type = "text/css">
  35. body {
  36. font-family:Arial, Helvetica, sans-serif;
  37. font-size:14px;
  38. }
  39.  
  40. label {
  41. font-weight:bold;
  42. width:100px;
  43. font-size:14px;
  44. }
  45.  
  46. .box {
  47. border:#666666 solid 1px;
  48. }
  49. </style>
  50.  
  51. </head>
  52.  
  53. <body bgcolor = "#FFFFFF">
  54.  
  55. <div align = "center">
  56. <div style = "width:300px; border: solid 1px #333333; " align = "left">
  57. <div style = "background-color:#343343; color:#FFFFFF; padding:4px;"><b><Login></b></div>
  58.  
  59. <div style = "margin:30px">
  60.  
  61. <form action = "" method = "post">
  62. <center><label>Username : </label><input type = "text" name = "username" class = "box"/><br /><br />
  63. <label>Password : </label><input type = "password" name = "password" class = "box" /><br/><br />
  64. <input type = "submit" value = " Login "/><br /></center>
  65. </form>
  66.  
  67. <div style = "font-size:11px; color:#cc0000; margin-top:10px"><?php echo $error; ?></div>
  68.  
  69. </div>
  70.  
  71. </div>
  72.  
  73. </div>
  74.  
  75. </body>
  76. </html>
Add Comment
Please, Sign In to add comment