File "submit.php"
Full Path: /home/humancap/cl.humancap.com.my/assessment/submit.php
File size: 1006 B
MIME-type: text/x-php
Charset: utf-8
<?php
require_once "include/config.php";
// Create a database connection
$conn = new mysqli($host, $username, $password, $database);
// Check the connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
if ($_SERVER["REQUEST_METHOD"] == "POST") {
// Retrieve JSON data from the form submission
$jsonAnswers = $_POST["jsonAnswers"];
$hashValue = $_POST["hash"];
echo $jsonAnswers;
echo $hashValue;
// exit();
// Insert the JSON data into your MySQL table
$sql = "UPDATE assessment_by_assessor SET status =2, data=? WHERE hash = ?";
$stmt = $conn->prepare($sql);
$stmt->bind_param("ss", $jsonAnswers, $hashValue);
if ($stmt->execute()) {
$stmt->close();
$conn->close();
header("Location: " . $_SERVER["HTTP_REFERER"]);
exit; // Make sure to exit the script after redirection
} else {
echo "Error: " . $stmt->error;
$stmt->close();
$conn->close();
}
}
?>