Create New Item
Item Type
File
Folder
Item Name
Search file in folder and subfolders...
Are you sure want to rename?
wobblies
/
admin
/
database
:
manage-plan-process.php
Advanced Search
Upload
New Item
Settings
Back
Back Up
Advanced Editor
Save
<?php ini_set('display_errors', 1); ini_set('display_startup_errors', 1); error_reporting(E_ALL); include 'head.php'; if($_SERVER['REQUEST_METHOD'] == "POST"){ $plan_title = $_POST['plan_title']; $minimum = $_POST['minimum']; $maximum = $_POST['maximum']; $profit = $_POST['profit']; $roi = $_POST['roi']; $days = $_POST['days']; $description = $_POST['description']; $image = $_FILES['image']; if(isset($_POST['btnSave'])){ // Handle image upload $imageName = $image['name']; $imageTmpName = $image['tmp_name']; $imageSize = $image['size']; $imageError = $image['error']; $imageType = $image['type']; $imageExt = strtolower(pathinfo($imageName, PATHINFO_EXTENSION)); $allowedExt = array('jpg', 'jpeg', 'png', 'webp', 'gif'); if(in_array($imageExt, $allowedExt)){ if($imageError === 0){ if($imageSize < 5000000){ // Limit file size to 5MB $imageNewName = uniqid('', true).".".$imageExt; $imageDestination = '../uploads/'.$imageNewName; if(move_uploaded_file($imageTmpName, $imageDestination)){ // Insert data into the database $sql = $conn->query("INSERT INTO plans (plan_title, minimum, maximum, profit, roi, days, description, image) VALUES ('$plan_title', '$minimum', '$maximum', '$profit', '$roi', '$days', '$description', '$imageNewName')"); if ($sql) { header("Location: manage-plan.php?uploadsuccess"); } else { echo "Database error: " . $conn->error; } } else { echo "Failed to upload image."; } } else { echo "Image file is too large. Maximum size is 5MB."; } } else { echo "Error uploading image."; } } else { echo "Invalid image file type. Allowed types: jpg, jpeg, png, gif."; } } if(isset($_POST['btnSaveUpdate'])){ $id = $_POST['id']; $sql = $conn->query("UPDATE plans SET plan_title='$plan_title', minimum='$minimum', maximum='$maximum', profit='$profit', roi='$roi', days='$days', description='$description' WHERE id='$id'"); header("Location: manage-plan.php"); } } ?>