Gravi's Forum Posts

  • 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);

    ?>

  • <?php

    // Allow from any origin

    if (isset($_SERVER['HTTP_ORIGIN'])) {

    // Decide if the origin in $_SERVER['HTTP_ORIGIN'] is one you want to allow, and if so:

    header("Access-Control-Allow-Origin: {$_SERVER['HTTP_ORIGIN']}");

    header('Access-Control-Allow-Credentials: true');

    header('Access-Control-Max-Age: 86400'); // cache for 1 day

    }

    // Access-Control headers are received during OPTIONS requests

    if ($_SERVER['REQUEST_METHOD'] == 'OPTIONS') {

    if (isset($_SERVER['HTTP_ACCESS_CONTROL_REQUEST_METHOD']))

    header("Access-Control-Allow-Methods: GET, POST, OPTIONS");

    if (isset($_SERVER['HTTP_ACCESS_CONTROL_REQUEST_HEADERS']))

    header("Access-Control-Allow-Headers: {$_SERVER['HTTP_ACCESS_CONTROL_REQUEST_HEADERS']}");

    exit(0);

    }

    // Database connection details

    $servername = "localhost";

    $username = "id22078763_db";

    $password = "Db@user5";

    $dbname = "id22078763_store";

    // Create connection

    $conn = new mysqli($servername, $username, $password, $dbname);

    // Check connection

    if ($conn->connect_error) {

    die("Connection failed: " . $conn->connect_error);

    }

    // Check if the request method is POST

    if ($_SERVER["REQUEST_METHOD"] == "POST") {

    // Get the score and player name from the POST data

    $score = $_POST['score'];

    $playerName = $_POST['playerName'];

    // Check if the player exists

    $sql = "SELECT id FROM users WHERE name = ?";

    $stmt = $conn->prepare($sql);

    $stmt->bind_param("s", $playerName);

    $stmt->execute();

    $result = $stmt->get_result();

    if ($result->num_rows > 0) {

    // Player exists, update their score

    $updateSql = "UPDATE users SET score = ? WHERE name = ?";

    $updateStmt = $conn->prepare($updateSql);

    $updateStmt->bind_param("is", $score, $playerName);

    $updateStmt->execute();

    echo "Score updated successfully";

    } else {

    // Player doesn't exist, insert a new record

    $insertSql = "INSERT INTO users (name, score) VALUES (?, ?)";

    $insertStmt = $conn->prepare($insertSql);

    $insertStmt->bind_param("si", $playerName, $score);

    $insertStmt->execute();

    echo "New record created successfully";

    }

    $stmt->close();

    }

    // Close the database connection

    $conn->close();

    ?>

    On Sql I have

    users table

    in this table

    name and score

    and im trying to post score

    getting error

    i dont know what's going wrong

    Tagged:

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • i face as same

  • Android And Windows Devices Text works properly As Center.

    But ios devices not

    Tagged:

  • drive.google.com/file/d/1KrWNQYMKwjN_-BiKuazLAEkYlyVDt2R-/view

    can you suggest me

    right way please

  • Ah Bro your Right,

    but How can i Compare with sprite.letter

    compare 2 values

    sprite.letter = LayoutA

    create Object

    like that ?

  • I have 3 Text In Layout2

    so i want to Create object is stored in another layout

    with comparing same values

    example image -

    Tagged:

  • So I Want To Connect Rest Api To My Construct Project

    SO I NEED TO MAKE SOME CHANGES INTO PROJECT USING VS CODE

    HOW TO DO THAT

    I installed Both Plugins Into My Construct Editor And VsCode Also

    Thanx Construct Users

    Tagged:

  • yes bro, i help you

    Can you record Video Or Image For Understand Better.

  • You can use local storage for , storing items.

  • You do not have permission to view this post

  • object follow border or edges on sprite

    i found example in example browser

    editor.construct.net

  • if Have many projects export

    for each project i do

    Menu > Project > Export > HTML >

    So Any shortcut Key Available For

    Direct HTML Options

    its too Lengthy When i Export 20+ Projects

    Tagged:

  • did you check

    Construct editor Examples

    i found example as same related that your idea

    in

    construct editor examples

    check it out

    editor.construct.net

  • You can found eraser in sprite editor