D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
home3
/
encodto1
/
bambooinn.in
/
admin
/
Filename :
manage-package.php
back
Copy
<?php include'config.php'; include'function.php'; error_reporting(); $action = $_GET['action']; $action_title = stringModify($action); $item_title = ""; $item_duration = ""; $item_location = ""; $item_places = ""; $item_content = ""; $item_img1 = ""; $item_img2 = ""; $item_status = ""; if($action == 'delete_package'){ $del_id = $_GET['id']; $del_event = mysqli_query($conn, "DELETE FROM `tour_packages` WHERE tour_id = '$del_id'"); if ($del_event) { echo '<script>alert("Item data deleted.")</script>'; echo '<script> window.location.href = "tour-list.php";</script>'; } } if($action == 'edit_package'){ $edit_id = $_GET['id']; $view_event = mysqli_query($conn, "SELECT * FROM tour_packages WHERE tour_id = '$edit_id'"); while($row = mysqli_fetch_array($view_event)) { $item_title = $row['tour_title']; $item_duration = $row['tour_duration']; $item_location = $row['tour_location']; $item_places = $row['tour_places']; $item_content = $row['tour_content']; $item_img1 = $row['tour_img1']; $item_img2 = $row['tour_img2']; $item_status = $row['tour_status']; } } ?> <!doctype html> <html lang="en"> <head> <meta charset="utf-8" /> <title>Admin, Manage Tour Packages | <?php echo $company; ?></title> <?php include'style.php'; ?> </head> <body> <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="row"> <div class="col-12"> <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">Tour Title:</label> <input class="form-control" type="text" value="<?php echo $item_title; ?>" id="example-text-input" name="item_title" placeholder="Tour Title"> </div> <div class="mb-3"> <label for="example-text-input" class="form-label">Tour Duration:</label> <input class="form-control" type="text" value="<?php echo $item_duration; ?>" id="example-text-input" name="item_duration" placeholder="Tour Duration"> </div> <div class="mb-3"> <label for="example-text-input" class="form-label">Tour Address:</label> <input class="form-control" type="text" value="<?php echo $item_location; ?>" id="example-text-input" name="item_location" placeholder="Tour Address"> </div> <div class="mb-3"> <label for="example-text-input" class="form-label">Tour Places:</label> <input class="form-control" type="text" value="<?php echo $item_places; ?>" id="example-text-input" name="item_places" placeholder="Tour Places"> </div> <div class="mb-3"> <label for="example-text-input" class="form-label">Tour Image 1:</label> <input class="form-control" type="file" value="<?php echo $item_img1; ?>" id="example-img-input" name="item_img1" placeholder="Tour Image 1"> </div> <div class="mb-3"> <label for="example-text-input" class="form-label">Tour Image 2:</label> <input class="form-control" type="file" value="<?php echo $item_img2; ?>" id="example-img-input" name="item_img2" placeholder="Tour Image 2"> </div> <div class="mb-3"> <label for="example-text-input" class="form-label">Tour Content:</label> <textarea class="form-control" rows="5" type="text" id="example-msg-input" name="item_content" placeholder="Tour Content"><?php echo $item_content;?></textarea> </div> <div class="mb-3"> <label for="example-text-input" class="form-label">product 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> </div> </div> </div> <!-- end col --> </div> </div> </div> <?php include'right-sidebar.php'; ?> <?php include'script.php'; ?> </body> </html> <?php if (isset($_POST['add_package'])) { $item_title = $_POST['item_title']; $item_duration = $_POST['item_duration']; $item_location = $_POST['item_location']; $item_places = $_POST['item_places']; // $item_img1 = $_POST['item_img1']; // $item_img2 = $_POST['item_img2']; $item_content = $_POST['item_content']; $item_status = $_POST['item_status']; $uploaddir = 'tour-images'; if(!is_dir($uploaddir)){ mkdir($uploaddir); } $item_img1 = $_FILES['item_img1']['name']; $item_tmp1 = $_FILES['item_img1']['tmp_name']; $item_path1 = $uploaddir ."/". $item_img1; if(move_uploaded_file($item_tmp1, $item_path1)){ echo '<script>alert("Item Image1 uploaded.")</script>'; } else{ echo '<script>alert("Item Image1 not uploaded.")</script>'; } $item_img2 = $_FILES['item_img2']['name']; $item_tmp2 = $_FILES['item_img2']['tmp_name']; $item_pat21 = $uploaddir ."/". $item_img2; if(move_uploaded_file($item_tmp2, $item_path2)){ echo '<script>alert("Item Image2 uploaded.")</script>'; } else{ echo '<script>alert("Item Image2 not uploaded.")</script>'; } $insert_event = "INSERT into tour_packages() values('', '$item_title', '$item_duration', '$item_location', '$item_places', '$item_content', '$item_img1', '$item_img2', '$item_status')"; $run_query = mysqli_query($conn, $insert_event) or mysqli_error($conn); if ($run_query){ echo '<script>alert("Item data uploaded.")</script>'; echo '<script> window.location.href = "tour-list.php";</script>'; } else{ echo '<script>alert("Item data not uploaded.")</script>'; } } if (isset($_POST['edit_package'])) { $item_title = $_POST['item_title']; $item_duration = $_POST['item_duration']; $item_location = $_POST['item_location']; $item_places = $_POST['item_places']; // $item_img1 = $_POST['item_img1']; // $item_img2 = $_POST['item_img2']; $item_content = $_POST['item_content']; $item_status = $_POST['item_status']; $ItemImg_Condition1 = ''; $ItemImg_Condition2 = ''; if ($_FILES['item_img1']['name'] != '') { $item_img1 = $_FILES['item_img1']['name']; $itemImg_path1 = 'tour-images/'.$item_img1; move_uploaded_file($_FILES['item_img1']['tmp_name'], $itemImg_path1); $ItemImg_Condition1 = ", tour_img1='$item_img1'"; } if ($_FILES['item_img2']['name'] != '') { $item_img2 = $_FILES['item_img2']['name']; $itemImg_path2 = 'tour-images/'.$item_img2; move_uploaded_file($_FILES['item_img2']['tmp_name'], $itemImg_path2); $ItemImg_Condition2 = ", tour_img2='$item_img2'"; } $ItemImg_Condition = $ItemImg_Condition1 . $ItemImg_Condition2; $update_data = "UPDATE `tour_packages` SET `tour_title`='$item_title', `tour_duration`='$item_duration',`tour_location`='$item_location',`tour_places`='$item_places',`tour_content`='$item_content' $ItemImg_Condition, `tour_status`='$item_status' WHERE `tour_id` = '$edit_id'"; $run_query = mysqli_query($conn, $update_data) or mysqli_error($conn); if ($run_query){ echo '<script>alert("Item data edited.")</script>'; echo '<script> window.location.href = "tour-list.php";</script>'; } else{ echo '<script>alert("Item data not edited.")</script>'; } } ?>