Advertisement
Guest User

Untitled

a guest
Nov 30th, 2017
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.23 KB | None | 0 0
  1. <!DOCTYPE html>
  2.  
  3. <html lang="en" xmlns="http://www.w3.org/1999/xhtml">
  4. <body>
  5. <head>
  6. <meta charset="utf-8" />
  7. </head>
  8. <?php
  9.  
  10. $servername = "mysql.cba.pl";
  11. $username = "trusjan";
  12. $password ="Qwerty1";
  13. $dbname = "trusjan";
  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. $imie = $_POST["txt_imie"];
  24. $nazwisko = $_POST["txt_nazwisko"];
  25. $wiek = $_POST["cmb_wiek"];
  26. $plec = $_POST["radio_gender"];
  27.  
  28.  
  29. $image=addslashes(file_get_contents($_FILES['fileToUpload']['tmp_name']));
  30.  
  31. $target_dir = "Uploads/";
  32. $target_file=$target_dir. basename($_FILES["fileToUpload"]["name"]);
  33.  
  34. if(move_uploaded_file($_FILES["fileToUpload"]["tmp_name"],$target_file)){
  35. echo "The file has been uploaded <br> ";
  36. }
  37. else{
  38. echo "Sorry, there was en error <br>";}
  39.  
  40.  
  41. $sql = "INSERT INTO `tb_person`(`Imie`, `Nazwisko`, `Wiek`, `Plec`, `image`) VALUES ('$imie','$nazwisko','$wiek','$plec','$image')";
  42.  
  43. if ($conn->query($sql) === TRUE) {
  44. echo "New record created successfull";
  45. } else {
  46. echo "Error: " . $sql . "<br>" . $conn->error;
  47. }
  48.  
  49.  
  50.  
  51.  
  52. $conn->close();
  53. ?>
  54. </body>
  55. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement