/
var
/
www
/
barefootlaw.org
/
will-generator
/
Upload File
HOME
<?php session_start(); if (isset($_SESSION['session_id'])) { $session_id = $_SESSION['session_id']; if ($_SERVER["REQUEST_METHOD"] == "POST") { $servername = "localhost"; $username = "will_generator"; $password = "Gtscq_!hQnBDRC_u"; $dbname = "will_generator"; $conn = new mysqli($servername, $username, $password, $dbname); if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } $heir_name = isset($_POST['heir_name']) ? $_POST['heir_name'] : []; $heir_address = isset($_POST['heir_address']) ? $_POST['heir_address'] : []; $witness_name = isset($_POST['witness_name']) ? $_POST['witness_name'] : []; $witness_address = isset($_POST['witness_address']) ? $_POST['witness_address'] : []; $witness_signature = isset($_POST['witness_signature']) ? $_POST['witness_signature'] : []; $distribution_name = isset($_POST['distribution_name']) ? $_POST['distribution_name'] : []; $distribution = isset($_POST['distribution']) ? $_POST['distribution'] : []; $burry_wishes = isset($_POST['burry_wishes']) ? $_POST['burry_wishes'] : []; $other_wishes = isset($_POST['other_wishes']) ? $_POST['other_wishes'] : []; $charity = isset($_POST['charity']) ? $_POST['charity'] : []; $charity_distribution = isset($_POST['charity_distribution']) ? $_POST['charity_distribution'] : []; // Fetch data from the database using the existing connection object $conn $query = "SELECT distribution FROM will_info"; $result = $conn->query($query); // Store the fetched data in an array $data = array(); while ($row = $result->fetch_assoc()) { $data[] = $row; } // Send the data as JSON echo json_encode($data); if ($result) { $check_result = $result->num_rows; if ($check_result > 0) { $update_sql = "UPDATE will_info SET heir_name = " . (!empty($heir_name) ? "'" . implode(",", $heir_name) . "'" : "NULL") . ", heir_address = " . (!empty($heir_address) ? "'" . implode(",", $heir_address) . "'" : "NULL") . ", distribution_name = " . (!empty($distribution_name) ? "'" . implode(",", $distribution_name) . "'" : "NULL") . ", distribution = " . (!empty($distribution) ? "'" . implode(",", $distribution) . "'" : "NULL") . ", witness_name = " . (!empty($witness_name) ? "'" . implode(",", $witness_name) . "'" : "NULL") . ", witness_address = " . (!empty($witness_address) ? "'" . implode(",", $witness_address) . "'" : "NULL") . ", burry_wishes = " . (!empty($burry_wishes) ? "'" . implode(",", $burry_wishes) . "'" : "NULL") . ", other_wishes = " . (!empty($other_wishes) ? "'" . implode(",", $other_wishes) . "'" : "NULL") . ", charity = " . (!empty($charity) ? "'" . implode(",", $charity) . "'" : "NULL") . ", charity_distribution = " . (!empty($charity_distribution) ? "'" . implode(",", $charity_distribution) . "'" : "NULL") . ", session_id=LAST_INSERT_ID(session_id) WHERE session_id = '$session_id'"; if ($conn->query($update_sql) === TRUE) { $last_id = $conn->insert_id; header("Location: download.php?id=" . $last_id); exit(); } else { echo "Error updating record: " . $conn->error; } } } else { echo "Error: " . $conn->error; } $conn->close(); } } else { header("Location: log.php"); exit(); } ?>