Guest User

Untitled

a guest
Dec 6th, 2018
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. <html>
  2. <head>
  3. <title>imie</title>
  4. </head>
  5. <body>
  6. <?php
  7. $servername = "localhost";
  8. $dbname = "zadania";
  9. $username = "root";
  10. $password = "";
  11.  
  12. $connect = mysqli_connect($servername, $username, $password, $dbname);
  13.  
  14. if (!$connect) {
  15. die("Connection failed: " . mysqli_connect_error());
  16. }
  17. echo "Connected successfully";
  18. ?>
  19.  
  20. <form method="POST" action="Bartłomiej_Juda_Zadanie_5_4.php">
  21. <p><input type="text" name="imie1" size="20"> Podaj imie</p>
  22. <p><input type="submit" value="Dalej" name="przycisk"></p>
  23. </form>
  24.  
  25. <?php
  26. $imie = $_POST['imie1'];
  27. $zapytanie = "SELECT * FROM Studenci WHERE '$imie'=Imie";
  28. $result = mysqli_query($connect,$zapytanie);
  29.  
  30. if (mysqli_num_rows($result) > 0) {
  31.  
  32. while($row = mysqli_fetch_assoc($result)) {
  33. echo "id: " . $row["ID_Studenta"]. " - Imie: " . $row["Imie"]. " " . $row["Nazwisko"]. "<br>";
  34. }
  35. } else {
  36. echo "0 results";
  37. }
  38.  
  39. mysqli_close($connect);
  40. ?>
  41. </body>
  42. </html>
Add Comment
Please, Sign In to add comment