Advertisement
Guest User

php2,4

a guest
Mar 17th, 2019
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. -- 2 i 4 --
  2. <form action="" method="POST">
  3. <input name="imie" placeholder="imie"/>
  4. <input type="submit" value="Wyslij">
  5. </form>
  6.  
  7.  
  8. <?php
  9. if($_POST != null) {
  10. $imie = $_POST["imie"];
  11.  
  12. $servername = "localhost";
  13. $username = "root";
  14. $password = "";
  15. $dbname = "studenci";
  16.  
  17. // Create connection
  18. $conn = new mysqli($servername, $username, $password, $dbname);
  19. // Check connection
  20. if ($conn->connect_error) {
  21. die("Connection failed: " . $conn->connect_error);
  22. }
  23. $sql = "SELECT id, imie, nazwisko FROM student where imie = '$imie'";
  24. $result = $conn->query($sql);
  25.  
  26. if ($result->num_rows > 0) {
  27. while($row = $result->fetch_assoc()) {
  28. echo "id: " . $row["id"]. " - Imie i nazwisko: " . $row["imie"]. " " . $row["nazwisko"]. "<br>";
  29. }
  30. } else {
  31. echo "0 wynikow";
  32. }
  33. $conn->close();
  34.  
  35. }
  36. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement