|
Server IP : 217.21.85.138 / Your IP : 216.73.216.103 Web Server : LiteSpeed System : Linux in-mum-web906.main-hosting.eu 4.18.0-553.37.1.lve.el8.x86_64 #1 SMP Mon Feb 10 22:45:17 UTC 2025 x86_64 User : u915722082 ( 915722082) PHP Version : 7.4.33 Disable Function : system, exec, shell_exec, passthru, mysql_list_dbs, ini_alter, dl, symlink, link, chgrp, leak, popen, apache_child_terminate, virtual, mb_send_mail MySQL : OFF | cURL : ON | WGET : ON | Perl : OFF | Python : OFF Directory (0755) : /home/u915722082/.nvm/../public_html/invoice/ |
| [ Home ] | [ C0mmand ] | [ Upload File ] |
|---|
<?php
require_once 'db.php';
// Check connection
if ($con->connect_error) {
die(json_encode(['success' => false, 'message' => "Connection failed: " . $con->connect_error]));
}
if (isset($_POST['action']) && $_POST['action'] == 'update') {
$response = ['success' => true, 'message' => ''];
// Get package data from POST
$packageData = $_POST['package_data'];
// Start transaction
$con->begin_transaction();
try {
// Process each item in the package data
foreach ($packageData as $item) {
$name = $con->real_escape_string($item['name']);
$value = floatval($item['value']);
$bpid = intval($item['no_of_bpid']);
// Handle `no_of_pack`
if (is_array($item['no_of_pack'])) {
$no_of_pack = $con->real_escape_string(implode(',', $item['no_of_pack']));
} else {
$no_of_pack = $con->real_escape_string($item['no_of_pack']);
}
// Update SQL query
$sql = "UPDATE bulkpackage
SET bvalue = '$value',
bppaid = '$no_of_pack',
name = '$name'
WHERE bpid = $bpid";
if (!$con->query($sql)) {
throw new Exception("Error: " . $sql . "<br>" . $con->error);
}
}
// Commit transaction
$con->commit();
$response['message'] = 'Package configuration saved successfully.';
} catch (Exception $e) {
// Roll back transaction
$con->rollback();
$response['success'] = false;
$response['message'] = $e->getMessage();
}
// Close connection
$con->close();
// Return JSON response
header('Content-Type: application/json');
echo json_encode($response);
exit;
}
?>