Advertisement
Guest User

Untitled

a guest
Mar 6th, 2016
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.52 KB | None | 0 0
  1. Champ 'admin' inconnu dans where clause.
  2.  
  3. <body>
  4. <div class="container">
  5. <form id="signup" method="post" action="">
  6. <div class="header">
  7. <img src="admin/adminpanel.png">
  8.  
  9. </div>
  10.  
  11. <div class="sep"></div>
  12.  
  13. <div class="inputs">
  14. <input type="text" placeholder="Username" name="admin-username" />
  15. <input type="password" placeholder="Password" name="admin-password" />
  16.  
  17. <input type="Submit" Value="Sign Up"/>
  18. </div>
  19. </form>
  20. </div>
  21.  
  22.  
  23. <?php
  24. @mysql_connect('localhost', 'root', '');
  25.  
  26. $select_db = mysql_select_db('register');
  27.  
  28. session_start();
  29.  
  30. if (isset($_POST['admin-username'])){
  31. $username = $_POST['admin-username'];
  32. $password = $_POST['admin-password'];
  33.  
  34. $query = "SELECT * FROM `admin` WHERE admin-username='$username' and admin-password='$password' ";
  35. $result = mysql_query($query) or die(mysql_error());
  36. $rows = mysql_num_rows($result);
  37. if($rows==1){
  38. $_SESSION['admin-username'] = $username;
  39. header("Location: admin.php");
  40. }else{
  41. echo "<div class='form'><h3>Username/password is incorrect.</h3></div>";
  42. }
  43. }else
  44. ?>
  45. </body>
  46.  
  47. <?php
  48.  
  49. session_start();
  50.  
  51. $connection = new mysqli ("localhost", "root", "", "register");
  52. if ($connection -> connect_errno) {
  53. echo "Failed to connect to MySQL: (" . $mysqli->connect_errno . ") " . $mysqli->connect_error;
  54. }
  55.  
  56.  
  57. $select_db = mysqli_select_db($connection, 'register');
  58. if (!$select_db){
  59. die("Database Selection Failed" . mysql_error());
  60. }
  61.  
  62. if (isset($_POST['admin-username'])){
  63.  
  64. $username = $_POST['admin_username'];
  65. $password = $_POST['admin_password'];
  66.  
  67. $query = "SELECT * FROM `admin` WHERE admin_username='$username' and admin_password='$password'";
  68.  
  69. $result = mysqli_query($connection, $query)
  70. or die(mysql_error());
  71. $rows = mysqli_num_rows($result);
  72.  
  73. if ($rows == 1){
  74. header("Location:admin.php");
  75. $_SESSION['name'] = $username;
  76. }else{
  77. echo "Invalid Login Credentials.";
  78. }
  79. }
  80. ?>
  81.  
  82.  
  83. <html>
  84. <body>
  85. <form action="<?php $_PHP_SELF ?>" method="post">
  86.  
  87. <input type="text" name="admin_username">
  88. <input type="password" name="admin_password">
  89. <button type="submit" name="submit" value="submit" >
  90.  
  91. </form>
  92. </body>
  93. </html>
  94.  
  95. ___________________________________
  96. | admin_username | admin_password |
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement