Guest User

Untitled

a guest
Feb 14th, 2019
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.29 KB | None | 0 0
  1. <?php
  2.  
  3. $servername = "localhost";
  4. $username = "ido";
  5. $password = "idoserver1234";
  6. $dbname = "Ido";
  7.  
  8. // Create connection
  9. $conn = new mysqli($servername, $username, $password, $dbname);
  10. // Check connection
  11. if ($conn->connect_error) {
  12.     die("Connection failed: " . $conn->connect_error);
  13. }
  14.  
  15. if($_SERVER['REQUEST_METHOD'] == "POST") {
  16.     if($_POST["name"] != "" && $_POST["password"] != ""){
  17.      
  18.         $sql = "SELECT name,password FROM users WHEN password = '$_POST["password"]'";
  19.         $result = $conn->query($sql);
  20.  
  21.         if ($result->num_rows > 0) {
  22.             // output data of each row
  23.  
  24.               while($row = $result->fetch_assoc()) {
  25.                     print($row["name"] . "<br>");
  26.                 }
  27.  
  28.         } else {
  29.             echo "0 results";
  30.         }
  31.     } else {
  32.         header("Refresh:0");
  33.     }
  34. } else {
  35. ?>
  36. <html>
  37.     <body>
  38.         <form action="" method="POST">
  39.             Name: <input type="text" name="name"><br>
  40.             Password: <input type="password" name="password"><br>
  41.             <input type="submit" value="Sign In">
  42.         </form>
  43.         <a href="signup.php">
  44.             <button>Sign Up</button>
  45.         </a>
  46.     </body>
  47.     <link rel="stylesheet" type="text/css" href="style.css">
  48. </html>
  49. <?php }
  50.  
  51. $conn->close();
  52. ?>
Add Comment
Please, Sign In to add comment