daily pastebin goal
43%
SHARE
TWEET

Untitled

a guest Dec 7th, 2017 132 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. $servername = "mysql.cba.pl";
  3. $username = "evolse";
  4. $password = "Bazadanych1";
  5. $dbname = "evolse";
  6.  
  7. $imie = $_POST["txt_imie"];
  8. $nazwisko = $_POST["txt_nazwisko"];
  9. $wiek = $_POST["cmb_wiek"];
  10. $plec = $_POST["radio_plec"];
  11. $zainteresowania = $_POST["Zaint"];
  12. $zaint = implode(";",$zainteresowania);
  13. $zdjecie = addslashes(file_get_contents($_FILES['fileToUpload']['tmp_name']));
  14.  
  15.  
  16. // Create connection
  17. $conn = new mysqli($servername, $username, $password, $dbname);
  18. // Check connection
  19. if ($conn->connect_error) {
  20.     die("Connection failed: " . $conn->connect_error);
  21. }
  22.  
  23. $sql = "INSERT INTO tb_person (imie, nazwisko, wiek, plec, zainteresowania, zdjecie)
  24. VALUES ('$imie', '$nazwisko', '$wiek', '$plec', '$zaint', '$zdjecie')";
  25.  
  26. if ($conn->query($sql) === TRUE) {
  27.     echo "New record created successfully";
  28. } else {
  29.     echo "Error: " . $sql . "<br>" . $conn->error;
  30. }
  31.  
  32. $conn->close();
  33.  
  34.  
  35. // Wyswietlanie obrazka + bazy (tabeli)
  36.  
  37. // Create connection
  38. $conn = new mysqli($servername, $username, $password, $dbname);
  39. // Check connection
  40. if ($conn->connect_error) {
  41.     die("Connection failed: " . $conn->connect_error);
  42. }
  43.  
  44. $sql = "SELECT id, imie, nazwisko, plec, wiek, zainteresowania, zdjecie FROM tb_person";
  45. $result = $conn->query($sql);
  46. echo "<center><table border='2' width='20'><tr><th>ID</th><th>Imię</th><th>Nazwisko</th><th>Płeć</th><th>Wiek</th><th>Zainteresowania</th><th>Zdjęcie</th><th>EDIT</th><th>DELETE</tr>";
  47. if ($result->num_rows > 0) {
  48.     // output data of each row
  49.     while($row = $result->fetch_assoc()) {
  50. $zmienna = $row["id"];
  51.         echo "<tr><td>" . $row["id"]. "</td><td>" . $row["imie"]. "</td><td>" . $row["nazwisko"]. "</td><td>" . $row["plec"]. "</td><td>" . $row["wiek"]. "</td><td>" . $row["zainteresowania"]. "</td><td align='center'><a href =getimage.php?idd=$zmienna><img src='/img/zdjecie.png' height='20'></a></td><td align='center'><a href =''><img src='/img/edit.png' height='20'></a></td><td align='center'><a href =''><img src='/img/delete.png' height='20'></a></td></tr>";
  52.     }
  53. echo "</table></center>";
  54. } else {
  55.     echo "0 results";
  56. }
  57.  
  58. $conn->close();
  59.  
  60. ?>
RAW Paste Data
Top