Advertisement
Guest User

Untitled

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