Advertisement
Guest User

Untitled

a guest
May 23rd, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.58 KB | None | 0 0
  1. <?php
  2. include("Modules/config.php");
  3. session_start();
  4. $error = Null;
  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 prodyne WHERE username = '$myusername' and passcode = '$mypassword'";
  12. $result = mysqli_query($db,$sql);
  13. $row = mysqli_fetch_array($result,MYSQLI_ASSOC);//Error here Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given in C:\xampp\htdocs\ProdyneP\Index.php on line 14
  14.  
  15. $active = $row['active'];
  16.  
  17. $count = mysqli_num_rows($result); //and error here Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given in C:\xampp\htdocs\ProdyneP\Index.php on line 17
  18.  
  19.  
  20. // If result matched $myusername and $mypassword, table row must be 1 row
  21.  
  22. if($count == 1) {
  23. session_register("myusername");
  24. $_SESSION['login_user'] = $myusername;
  25.  
  26. header("location: welcome.php");
  27. }else {
  28. $error = "Your Login Name or Password is invalid";
  29. }
  30. }
  31. ?>
  32. <html>
  33.  
  34. <head>
  35. <title>Login Page</title>
  36.  
  37. <style type = "text/css">
  38. body {
  39. font-family:Arial, Helvetica, sans-serif;
  40. font-size:14px;
  41. }
  42.  
  43. label {
  44. font-weight:bold;
  45. width:100px;
  46. font-size:14px;
  47. }
  48.  
  49. .box {
  50. border:#666666 solid 1px;
  51. }
  52. </style>
  53.  
  54. </head>
  55.  
  56. <body bgcolor = "#FFFFFF">
  57.  
  58. <div align = "center">
  59. <div style = "width:300px; border: solid 1px #333333; " align = "left">
  60. <div style = "background-color:#333333; color:#FFFFFF; padding:3px;"><b>Login</b></div>
  61.  
  62. <div style = "margin:30px">
  63.  
  64. <form action = "" method = "post">
  65. <label>UserName :</label><input type = "text" name = "username" class = "box"/><br /><br />
  66. <label>Password :</label><input type = "password" name = "password" class = "box" /><br/><br />
  67. <input type = "submit" value = " Submit "/><br />
  68. </form>
  69.  
  70. <div style = "font-size:11px; color:#cc0000; margin-top:10px"><?php echo $error; ?></div>
  71.  
  72. </div>
  73.  
  74. </div>
  75.  
  76. </div>
  77.  
  78. </body>
  79. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement