Advertisement
Guest User

Untitled

a guest
Jan 27th, 2017
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.25 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 = "Your Login Name or Password is invalid";
  27. }
  28. }
  29. ?>
  30. <html>
  31.  
  32. <head>
  33. <title>Login Page</title>
  34.  
  35. <style type = "text/css">
  36. body {
  37. font-family:Arial, Helvetica, sans-serif;
  38. font-size:14px;
  39. }
  40.  
  41. label {
  42. font-weight:bold;
  43. width:100px;
  44. font-size:14px;
  45. }
  46.  
  47. .box {
  48. border:#666666 solid 1px;
  49. }
  50. </style>
  51.  
  52. </head>
  53.  
  54. <body bgcolor = "#FFFFFF">
  55.  
  56. <div align = "center">
  57. <div style = "width:300px; border: solid 1px #333333; " align = "left">
  58. <div style = "background-color:#333333; color:#FFFFFF; padding:3px;"><b>Login</b></div>
  59.  
  60. <div style = "margin:30px">
  61.  
  62. <form action = "" method = "post">
  63. <label>UserName :</label><input type = "text" name = "username" class = "box"/><br /><br />
  64. <label>Password :</label><input type = "password" name = "password" class = "box" /><br/><br />
  65. <input type = "submit" value = " Submit "/><br />
  66. </form>
  67.  
  68. <div style = "font-size:11px; color:#cc0000; margin-top:10px"><?php echo $error; ?></div>
  69.  
  70. </div>
  71.  
  72. </div>
  73.  
  74. </div>
  75.  
  76. </body>
  77. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement