Advertisement
Moravetskyi

Untitled

Sep 10th, 2014
205
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.80 KB | None | 0 0
  1. <?php
  2.  
  3. $connect = mysqli_connect('localhost', 'root', '12345', 'bugs');
  4. $result = mysqli_query($connect, "Select * from user");
  5.  
  6. if (mysqli_connect_errno()) {
  7. echo "Failed to connect to MySQL: " . mysqli_connect_error();
  8. }
  9.  
  10. //' OR 1=1 --' для того щоб перевірка бд давала завжди true
  11. $user_login = $_GET['login'];
  12. $user_password = $_GET['pass'];
  13.  
  14.  
  15. if (isset($_GET['login_b'])) {
  16.  
  17. $result = mysqli_query($connect, "Select * from user where login='$user_login' and password='$user_password'");
  18. $myrow = mysqli_fetch_assoc($result);
  19.  
  20.  
  21. if (!empty($myrow)) {
  22. echo "<p align=center>Hello," . $myrow['login'] . "</p>";
  23. } else {
  24. echo "<p align=center>Wrong login: " . $user_login . " Password: " . $user_password . "</p>";
  25. }
  26.  
  27. }
  28.  
  29. if (isset($_GET['reg'])) {
  30. $result = mysqli_query($connect, "insert into user (login,password) values ('$user_login','$user_password')");
  31. }
  32. mysqli_close($connect);
  33. ?>
  34.  
  35.  
  36.  
  37. <html>
  38. <head>
  39. <title>LogIn</title>
  40. </head>
  41. <body>
  42.  
  43. <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="get">
  44. <table align="center">
  45. <tr>
  46. <td><b>Login:</b></td>
  47. <td>
  48. <input type='text' name='login'>
  49. </td>
  50. </tr>
  51.  
  52.  
  53. <tr>
  54. <td><b>Password:</b></td>
  55. <td>
  56. <input type='text' name='pass'>
  57. </td>
  58. </tr>
  59.  
  60.  
  61. <tr>
  62. <td align="center" colspan='2'>
  63. <input id="button" name="login_b" style=" width: 110px;height: 50px" type='submit' value="Log In">
  64. <input id="button" name="reg" style="width: 110px;height: 50px" type='submit' value="Registration">
  65. </td>
  66.  
  67. </tr>
  68.  
  69. </table>
  70. </form>
  71. </body>
  72. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement