Guest User

Untitled

a guest
Apr 15th, 2018
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.64 KB | None | 0 0
  1. <?php
  2.  
  3. $servername = "localhost";
  4. $username = "root";
  5. $password = "";
  6. $dbname = "Lusers";
  7. // Create connection
  8. $conn_statue = mysqli_connect($servername, $username, $password,$dbname);
  9.  
  10.  
  11. $conn_statue->query("set name utf8");
  12. $conn_statue->query("set character set utf8");
  13. session_start();
  14.  
  15. if($_SERVER["REQUEST_METHOD"] == "POST") {
  16. // username and password sent from form
  17.  
  18. $myusername = mysqli_real_escape_string($db,$_POST['username']);
  19. $mypassword = mysqli_real_escape_string($db,$_POST['password']);
  20.  
  21. $sql = "SELECT id FROM admin WHERE username = '$myusername' and passcode = '$mypassword'";
  22. $result = mysqli_query($db,$sql);
  23. $row = mysqli_fetch_array($result,MYSQLI_ASSOC);
  24. $active = $row['active'];
  25.  
  26. $count = mysqli_num_rows($result);
  27.  
  28. // If result matched $myusername and $mypassword, table row must be 1 row
  29.  
  30. if($count == 1) {
  31. session_register("myusername");
  32. $_SESSION['login_user'] = $myusername;
  33.  
  34. header("location: welcome.php");
  35. }else {
  36. $error = "Your Login Name or Password is invalid";
  37. }
  38. }
  39. ?>
  40. <html>
  41.  
  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. label {
  51. font-weight:bold;
  52. width:100px;
  53. font-size:14px;
  54. }
  55. .box {
  56. border:#666666 solid 1px;
  57. }
  58. </style>
  59.  
  60. </head>
  61.  
  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 method = "post" action = "config.php" >
  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. <a href="sign_up1.php">
  75. <input type = "submit" value = " تسجيل جديد " >
  76. </a>
  77.  
  78. </form>
  79.  
  80. <div style = "font-size:11px; color:#cc0000; margin-top:10px">
  81.  
  82. </div>
  83.  
  84. </div>
  85.  
  86. </div>
  87.  
  88.  
  89. </body>
  90. </html>
Add Comment
Please, Sign In to add comment