<?php
    session_start();
    include "../../connect/db.php";

    if (isset($_POST['stellar'])) {

        // Sanitize POST data
        $email22 = mysqli_real_escape_string($con, $_POST['email22']);
        $stellar = mysqli_real_escape_string($con, $_POST['stellar']);
        $tether = mysqli_real_escape_string($con, $_POST['tether']);
        $bitcoin = mysqli_real_escape_string($con, $_POST['bitcoin']);
        $bitcoincash = mysqli_real_escape_string($con, $_POST['bitcoincash']);
        $litecoin = mysqli_real_escape_string($con, $_POST['litecoin']);
        $ripple = mysqli_real_escape_string($con, $_POST['ripple']);
        $tron = mysqli_real_escape_string($con, $_POST['tron']);

        // Update query
        $sql = mysqli_query($con, "UPDATE usercrypto SET 
            stellar = '$stellar',
            tether = '$tether',
            bitcoin = '$bitcoin',
            bitcoincash = '$bitcoincash',
            litecoin = '$litecoin',
            ripple = '$ripple',
            tron = '$tron'
        WHERE user = '$email22'");

        // Check query execution
        if ($sql) {
            echo "success";
        } else {
            echo "Error: " . mysqli_error($con);
        }
    }
?>
