Advertisement
Guest User

Untitled

a guest
Feb 20th, 2017
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.84 KB | None | 0 0
  1. <?php
  2. if(isset($_POST['submit'])){
  3. try{
  4.  
  5. $sql = "INSERT INTO tour (tour_title,tour_content,price,highlight,amenities,terms,map) VALUES(:tour_title, :tour_content, :price, :highlight, :amenities, :terms., :map)";
  6. $stmt = $db->prepare($sql);
  7. $stmt->bindParam(':tour_title', $tour_title, PDO::PARAM_STR);
  8. $stmt->bindParam(':tour_content', $tour_content, PDO::PARAM_STR);
  9. $stmt->bindParam(':price', $price, PDO::PARAM_STR);
  10. $stmt->bindParam(':highlight', $highlight, PDO::PARAM_STR);
  11. $stmt->bindParam(':amenities', $amenities, PDO::PARAM_STR);
  12. $stmt->bindParam(':terms', $terms, PDO::PARAM_STR);
  13. $stmt->bindParam(':map', $map, PDO::PARAM_STR);
  14. //$stmt->bindParam(':tour_pic', $userpic);
  15.  
  16. $tour_title = $_POST['tour_title'];
  17. $tour_content = $_POST['tour_content'];
  18. $price = $_POST['price'];
  19. $highlight = $_POST['highlight'];
  20. $amenities = $_POST['amenities'];
  21. $terms = $_POST['terms'];
  22. $map = $_POST['map'];
  23.  
  24. $query = "SELECT max(id) id FROM tour";
  25. $stmt1 = $db->prepare($query);
  26. $stmt1->execute();
  27.  
  28. $record = $stmt1->fetch(PDO::FETCH_ASSOC);
  29.  
  30. if(isset($_FILES['media'])){
  31. $id = $record['id'];
  32. $imgFile = $_FILES['media']['name'];
  33. $tmp_dir = $_FILES['media']['tmp_name'];
  34. $imgSize = $_FILES['media']['size'];
  35.  
  36. $upload_dir = 'images/'; // upload directory
  37. for($i = 0; $i < count($tmp_dir); $i++)
  38. {
  39. if(move_uploaded_file($tmp_dir[$i], "images/".$imgFile[$i])){
  40. $query="INSERT INTO pics (owner, pic) VALUES(".$id.", '".$imgFile[$i]."')";
  41. $stmt2 = $db->prepare($query);
  42. $stmt2->execute();
  43. }
  44. }
  45. }
  46.  
  47. $stmt->execute();
  48. echo 'Package added successfully';
  49.  
  50. }catch(PDOException $e)
  51. {
  52. echo "Error: " . $e->getMessage();
  53. }
  54. }
  55. $db = null;
  56. ?>`
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement