Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <td><select name="img_lvm" id="img_lvm" >
- <option>--Select--</option>
- <?php
- $hostname = "xxx";
- $user = "xxx";
- $password = "xxx";
- $db = "xxx";
- $conn = mysqli_connect($hostname, $user, $password, $db);
- $result = mysqli_query($conn, "select luchtvaartmaatschappijID, luchtvaartmaatschappij from tbl_luchtvaartmaatschappij WHERE inactive='0' Order by luchtvaartmaatschappij ASC");
- while($row = mysqli_fetch_array($result))
- {
- $lvID = $row['luchtvaartmaatschappijID'];
- $l = $row['luchtvaartmaatschappij'];
- $iata = $row['IATACode'];
- echo "<option value='$lvID'>$iata - $l</option>";
- }mysqli_close($conn);
- ?>
- </select></td>
- <?php
- error_reporting( ~E_NOTICE ); // avoid notice
- require_once 'dbconfig.php';
- if(isset($_POST['btnsave']))
- {
- $location = $_POST['img_location'];// location where photo was taken
- $lvm = $_POST['img_lvm'];// airline of photo
- $date = date('Y-m-d', strtotime($_POST['img_date'])); // date of photo
- $img_t = $_POST['img_t'];// aircraft in photo
- $img_nmr = $_POST['img_nmr'];// registration of aircraft in photo
- $img_comments = $_POST['img_comments'];// photo comments
- $imgFile = $_FILES['img_file']['name'];
- $tmp_dir = $_FILES['img_file']['tmp_name'];
- $imgSize = $_FILES['img_file']['size'];
- if(empty($location)){
- $errMSG = "Please Enter Location where Photo Was Taken.";
- }
- else if(empty($lvm)){
- $errMSG = "Please Enter the Airline.";
- }
- else if(empty($img_t)){
- $errMSG = "Please Enter the Aircraft.";
- }
- else if(empty($imgFile)){
- $errMSG = "Please Select Image File.";
- }
- else
- {
- $upload_dir = '/home/xxx/public_html/vg/img/random/' .$lvm . '/'; // upload directory
- if (!is_dir('/home/xxx/public_html/vg/img/random/'.$lvm .'/')) {
- mkdir('/home/xxx/public_html/vg/img/random/' . $lvm .'/', 0777, TRUE);
- }
- $imgExt = strtolower(pathinfo($imgFile,PATHINFO_EXTENSION)); // get image extension
- // valid image extensions
- $valid_extensions = array('jpeg', 'jpg', 'png', 'gif'); // valid extensions
- // rename uploading image
- $img_file = rand(1000000000,1000000000000).".".$imgExt;
- // allow valid image file formats
- if(in_array($imgExt, $valid_extensions)){
- // Check file size '5MB'
- if($imgSize < 5000000) {
- move_uploaded_file($tmp_dir,$upload_dir.$img_file);
- }
- else{
- $errMSG = "Sorry, your file is too large.";
- }
- }
- else{
- $errMSG = "Sorry, only JPG, JPEG, PNG & GIF files are allowed.";
- }
- }
- // if no error occured, continue ....
- if(!isset($errMSG))
- {
- $stmt = $DB_con->prepare('INSERT INTO tbl_random(img_location,img_lvm,img_file, img_date, img_t, img_nmr, img_comments) VALUES(:i_loc, :i_lvm, :img_file, :img_date, :img_t, :img_nmr, :img_comments)');
- $stmt->bindParam(':i_loc',$location);
- $stmt->bindParam(':i_lvm',$lvm);
- $stmt->bindParam(':img_file',$img_file);
- $stmt->bindParam(':img_date',$img_date);
- $stmt->bindParam(':img_t',$img_t);
- $stmt->bindParam(':img_nmr',$img_nmr);
- $stmt->bindParam(':img_comments',$img_comments);
- if($stmt->execute())
- {
- $successMSG = "new record successfully inserted ...";
- header("refresh:1;index.php"); // redirects image view page after 1 seconds.
- }
- else
- {
- $errMSG = "error while inserting....";
- }
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement