Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- if(isset($_POST['submit'])){
- try{
- $sql = "INSERT INTO tour (tour_title,tour_content,price,highlight,amenities,terms,map) VALUES(:tour_title, :tour_content, :price, :highlight, :amenities, :terms., :map)";
- $stmt = $db->prepare($sql);
- $stmt->bindParam(':tour_title', $tour_title, PDO::PARAM_STR);
- $stmt->bindParam(':tour_content', $tour_content, PDO::PARAM_STR);
- $stmt->bindParam(':price', $price, PDO::PARAM_STR);
- $stmt->bindParam(':highlight', $highlight, PDO::PARAM_STR);
- $stmt->bindParam(':amenities', $amenities, PDO::PARAM_STR);
- $stmt->bindParam(':terms', $terms, PDO::PARAM_STR);
- $stmt->bindParam(':map', $map, PDO::PARAM_STR);
- //$stmt->bindParam(':tour_pic', $userpic);
- $tour_title = $_POST['tour_title'];
- $tour_content = $_POST['tour_content'];
- $price = $_POST['price'];
- $highlight = $_POST['highlight'];
- $amenities = $_POST['amenities'];
- $terms = $_POST['terms'];
- $map = $_POST['map'];
- $query = "SELECT max(id) id FROM tour";
- $stmt1 = $db->prepare($query);
- $stmt1->execute();
- $record = $stmt1->fetch(PDO::FETCH_ASSOC);
- if(isset($_FILES['media'])){
- $id = $record['id'];
- $imgFile = $_FILES['media']['name'];
- $tmp_dir = $_FILES['media']['tmp_name'];
- $imgSize = $_FILES['media']['size'];
- $upload_dir = 'images/'; // upload directory
- for($i = 0; $i < count($tmp_dir); $i++)
- {
- if(move_uploaded_file($tmp_dir[$i], "images/".$imgFile[$i])){
- $query="INSERT INTO pics (owner, pic) VALUES(".$id.", '".$imgFile[$i]."')";
- $stmt2 = $db->prepare($query);
- $stmt2->execute();
- }
- }
- }
- $stmt->execute();
- echo 'Package added successfully';
- }catch(PDOException $e)
- {
- echo "Error: " . $e->getMessage();
- }
- }
- $db = null;
- ?>`
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement