i changed the php script
now no any error and browser console and data submitted successfully from c3 project
but not reflecting in sql table
table name - users
name and score
<?php
header("Access-Control-Allow-Origin: *");
header("Access-Control-Allow-Methods: GET, POST, PUT, DELETE, OPTIONS");
header("Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept");
// Database connection details
$db = "id22078763_store"; // Your database name
$dbu = "id22078763_db"; // Your database username
$dbp = "Db@user5"; // Your database users' password
$host = "localhost"; // MySQL server - usually localhost
// Connect to the database
$dblink = mysqli_connect($host, $dbu, $dbp, $db);
// Check the connection
if (!$dblink) {
die("Connection failed: " . mysqli_connect_error());
}
if (isset($_GET['name']) && isset($_GET['score'])) {
// Lightly sanitize the GET parameters
$name = mysqli_real_escape_string($dblink, $_GET['name']);
$score = mysqli_real_escape_string($dblink, $_GET['score']);
// Insert the score into the database
$sql = "INSERT INTO `users` (`name`, `score`) VALUES ('$name', '$score')";
if (mysqli_query($dblink, $sql)) {
echo 'Your score was saved. Congrats!';
} else {
// Log or echo the error message if the query fails
echo 'There was a problem saving your score. Please try again later. Error: ' . mysqli_error($dblink);
}
} else {
echo 'Your name or score was not passed in the request. Make sure you add ?name=NAME_HERE&score=1337 to the URL.';
}
// Close the MySQL connection
mysqli_close($dblink);
?>