Guest User

Untitled

a guest
Mar 27th, 2018
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.48 KB | None | 0 0
  1. <?php
  2. if(isset($_POST["submit"]))
  3. {
  4. $check1 = getimagesize($_FILES["image1"]["tmp_name"]);
  5. $check2 = getimagesize($_FILES["image2"]["tmp_name"]);
  6. $check3 = getimagesize($_FILES["image3"]["tmp_name"]);
  7.  
  8. if($check1 !== false and $check2 !== false and $check3 !== false)
  9. {
  10.  
  11. $img1 = $_FILES['image1']['tmp_name'];
  12. $imgContent1 = addslashes(file_get_contents($img1));
  13. $frontimg = $imgContent1;
  14.  
  15. $img2 = $_FILES['image2']['tmp_name'];
  16. $imgContent2 = addslashes(file_get_contents($img2));
  17. $backimg = $imgContent2;
  18.  
  19. $img3 = $_FILES['image3']['tmp_name'];
  20. $imgContent3 = addslashes(file_get_contents($img3));
  21. $intimg = $imgContent3;
  22.  
  23. $kms = htmlentities($_POST["kms"]);
  24. $make = htmlentities($_POST["make"]);
  25. $model = htmlentities($_POST["model"]);
  26. $variant = htmlentities($_POST["variant"]);
  27. $reg = htmlentities($_POST["year"]);
  28. $color = htmlentities($_POST["color"]);
  29. $owner = htmlentities($_POST["owner"]);
  30. $price = htmlentities($_POST["price"]);
  31.  
  32. $dbHost = 'localhost';
  33. $dbUsername = 'root';
  34. $dbPassword = '';
  35. $dbName = 'car';
  36.  
  37.  
  38. $db = new mysqli($dbHost, $dbUsername, $dbPassword, $dbName);
  39.  
  40. // Check connection
  41. if($db->connect_error)
  42. {
  43. die("Connection failed: " . $db->connect_error);
  44. }
  45. $insert = $db->query(" insert into car( frontimg, backimg, intimg, kms, make, model, variant, reg, color, owner, price )
  46. values ('$frontimg', '$backimg', '$intimg','$kms','$make', '$model', '$variant', '$reg', '$color',
  47. '$owner','$price') ");
  48.  
  49. if($insert)
  50. {
  51.  
  52. echo "data stored successfully";
  53.  
  54. }
  55. else
  56. {
  57. echo "Check your query";
  58. }
  59.  
  60. }
  61. }
  62. ?>
Add Comment
Please, Sign In to add comment