Guest User

Untitled

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