D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
home3
/
encodto1
/
bambooinn.in
/
admin
/
Filename :
manage-travel-package.php
back
Copy
<?php include'config.php'; include'function.php'; error_reporting(); $action = $_GET['action']; $action_title = stringModify($action); $item_type = ""; $item_title = ""; $item_duration = ""; $item_place = ""; $item_status = ""; $item_img = ""; if($action == 'delete_travel'){ $del_id = $_GET['id']; $del_event = mysqli_query($conn, "DELETE FROM `travel_package` WHERE travel_id = '$del_id'"); if ($del_event) { echo '<script>alert("Travel Package data deleted.")</script>'; echo '<script> window.location.href = "blog-list.php";</script>'; } } if($action == 'edit_travel'){ $edit_id = $_GET['id']; $view_event = mysqli_query($conn, "SELECT * FROM `travel_package` WHERE travel_id = '$edit_id'"); while($row = mysqli_fetch_array($view_event)) { $item_type = $row['travel_type']; $item_title = $row['travel_title']; $item_duration = $row['travel_duration']; $item_place = $row['travel_place']; $item_status = $row['travel_status']; $item_img = $row['travel_img']; } } ?> <!doctype html> <html lang="en"> <head> <meta charset="utf-8" /> <title>Admin, Manage Travel Packages| Jungle Bell Resort</title> <?php include'style.php'; ?> </head> <body> <!-- Begin page --> <div id="layout-wrapper"> <?php include'header.php'; ?> <div class="main-content"> <div class="page-content"> <div class="container-fluid"> <div class="row"> <div class="col-12"> <div class="page-title-box d-sm-flex align-items-center justify-content-between"> <h4 class="mb-sm-0 font-size-18"><?php echo $action_title; ?></h4> <div class="page-title-right"> <ol class="breadcrumb m-0"> <li class="breadcrumb-item"><a href="./">Admin</a></li> <li class="breadcrumb-item active"><?php echo $action_title; ?></li> </ol> </div> </div> </div> </div> <div class="card"> <div class="card-body p-4"> <div class="row"> <div class="col-lg-6"> <form action="" method="POST" enctype="multipart/form-data" > <div class="mb-3"> <label for="example-text-input" class="form-label">travel title:</label> <input class="form-control" type="text" value="<?php echo $item_title; ?>" id="example-text-input" name="item_title" placeholder="Travel Title"> </div> <div class="mb-3"> <label for="example-text-input" class="form-label">travel duration:</label> <input class="form-control" type="text" value="<?php echo $item_duration; ?>" name="item_duration" placeholder="Travel Duration"> </div> <div class="mb-3"> <label for="example-text-input" class="form-label">travel type:</label> <input class="form-control" type="text" value="<?php echo $item_type; ?>" name="item_type" placeholder="Travel Type (Corporate/Wedding/Creative)."> </div> <div class="mb-3"> <label for="example-text-input" class="form-label">travel Place:</label> <input class="form-control" type="text" value="<?php echo $item_place; ?>" name="item_place" placeholder="Travel Place"> </div> <div class="mb-3"> <label for="example-text-input" class="form-label">travel Image:</label> <input class="form-control" type="file" name="item_img" placeholder="Travel Image"> </div> <div class="mb-3"> <label for="example-text-input" class="form-label">travel status:</label> <!-- <input type="text" class="form-control" name="item_status" placeholder="" value="<?php echo $item_status;?>"> --> <?php if($item_status == 1){ echo '<div class="form-check"> <input class="form-check-input" type="radio" name="item_status" id="flexRadioDefault1" value="1" checked> <label class="form-check-label" for="flexRadioDefault1">Active</label> </div> <div class="form-check"> <input class="form-check-input" type="radio" name="item_status" id="flexRadioDefault2" value="0"> <label class="form-check-label" for="flexRadioDefault2">Inactive</label> </div>'; } elseif ($item_status == 0) { echo '<div class="form-check"> <input class="form-check-input" type="radio" name="item_status" id="flexRadioDefault1" value="1" > <label class="form-check-label" for="flexRadioDefault1">Active</label> </div> <div class="form-check"> <input class="form-check-input" type="radio" name="item_status" id="flexRadioDefault2" value="0" checked> <label class="form-check-label" for="flexRadioDefault2">Inactive</label> </div>'; } else{ echo '<div class="form-check"> <input class="form-check-input" type="radio" name="item_status" id="flexRadioDefault1" value="1" checked> <label class="form-check-label" for="flexRadioDefault1">Active</label> </div> <div class="form-check"> <input class="form-check-input" type="radio" name="item_status" id="flexRadioDefault2" value="0"> <label class="form-check-label" for="flexRadioDefault2">Inactive</label> </div>'; }?> </div> <div class="mt-4"> <div class="btn_div"> <button type="submit" name="<?php echo $action; ?>" class="btn btn-primary w-md btn_manage"><?php echo $action_title; ?></button> </div> </div> </form> </div> <div class="col-lg-6 col-sm-6 col-xs-12"> <div class="data_img"> <img src="travel-images/<?php echo $item_img; ?>" style="height:200px;width: auto;"> </div> </div> </div> </div> </div> </div> </div> <?php include'right-sidebar.php'; ?> <?php include'script.php'; ?> </body> </html> <?php if (isset($_POST['add_travel'])) { $item_title = $_POST['item_title']; $item_duration = $_POST['item_duration']; $item_type = $_POST['item_type']; $item_place = $_POST['item_place']; $item_status = $_POST['item_status']; if ($_POST['item_status'] != '') {$item_status = $_POST['item_status'];} else{ $item_status = 0;} $uploaddir = 'travel-images'; if(!is_dir($uploaddir)){ mkdir($uploaddir); } $item_img = $_FILES['item_img']['name']; $item_tmp = $_FILES['item_img']['tmp_name']; $item_path = $uploaddir ."/". $item_img; if(move_uploaded_file($item_tmp, $item_path)){ echo $insrt_item = "insert into travel_package(travel_id, travel_title, travel_place, travel_duration, travel_img, travel_type, travel_status) values('', '$item_title', '$item_place', '$item_duration', '$item_img', '$item_type', '$item_status')"; $run_query = mysqli_query($conn, $insrt_item); if ($run_query){ echo '<script>alert("Blog data uploaded.")</script>'; echo '<script> window.location.href = "travel-package.php";</script>'; } else{ echo '<script>alert("Blog data not uploaded.")</script>'; } } else{ echo '<script>alert("Blog image not uploaded.")</script>'; } } if (isset($_POST['edit_travel'])) { $item_title = $_POST['item_title']; $item_duration = $_POST['item_duration']; $item_type = $_POST['item_type']; $item_place = $_POST['item_place']; $item_status = $_POST['item_status']; $itemImg_Condition = ''; if ($_FILES['item_img']['name'] != '') { $item_img = $_FILES['item_img']['name']; $itemImg_path = 'travel-images/'.$item_img; move_uploaded_file($_FILES['item_img']['tmp_name'], $itemImg_path); $itemImg_Condition = ", travel_img='$item_img'"; } echo $update_item = "UPDATE `travel_package` SET `travel_type`='$item_type', `travel_title`='$item_title',`travel_duration`='$item_duration',`travel_place`='$item_place',`travel_status`='$item_status' $itemImg_Condition WHERE `travel_id` = '$edit_id'"; $run_query = mysqli_query($conn, $update_item); if ($run_query){ echo '<script>alert("Travel package edited.")</script>'; echo '<script> window.location.href = "travel-packages.php";</script>'; } else{ echo '<script>alert("Travel package not edited.")</script>'; } } ?>