Visualizzazione dei risultati da 1 a 2 su 2

Hybrid View

  1. #1
    Utente di HTML.it
    Registrato dal
    Oct 2011
    Messaggi
    193
    codice HTML:
    ...
    <td><input type="text" value="<?php echo $Cart03; ?>" id="<?php echo $Cart06; ?>"></td>
    <td><input type="text" value="<?php echo $Cart04; ?>" id="<?php echo $Cart06; ?>"></td>
    <td><button onclick="aggiornaDato(<?php echo $Cart06; ?>, <?php echo $Cart03; ?>, <?php echo $Cart04; ?>)">Aggiorna!</button></td>
    ...
    <script>
    function aggiornaDato(id, tess, cart) {
        fetch('update_Cartellino.php', {
            method: 'POST',
            headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
            body: `id=${id}&tess=${tess}&cart=${cart}`
        })
        .then(response => response.text())
        .then(data => {
            if(data === "success") {
                document.getElementById(id).innerText = nTess;
                alert("Dato aggiornato con successo!");
            }
        });
    }
    </script>
    ...
    e
    Codice PHP:
    <?php
    if(isset($_POST['id'], $_POST['tess'], $_POST['cart'])) {
    $id $_POST['id'];
    $tess $_POST['tess'];
    $cart $_POST['cart'];
    $stmt $cndb->prepare("UPDATE `tabella` SET `Ntessera` = ?, `Cartellino` = ? WHERE `ID` = '" $id "'");
    $stmt->bind_param('i'$tess$cart);
    if (
    $stmt->execute()) {        echo "success";
    } else {        echo 
    "error";
    }
    $stmt->close();
    }
    } else {
    echo 
    'non atteso';
    }
    ?>
    Ultima modifica di darbula; 04-01-2026 a 14:31

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2026 vBulletin Solutions, Inc. All rights reserved.