Visualizzazione dei risultati da 1 a 10 su 17

Visualizzazione discussione

  1. #4
    Utente di HTML.it
    Registrato dal
    Dec 2023
    Messaggi
    17
    codice HTML:
    <?php
        // Recupera i valori precedenti
        $myfile  = fopen("data.txt", "r") or die("Unable to open file!");
        $read = fread($myfile,filesize("data.txt"));
        echo "--- Ripristina Data ---<br><br>";
        $separator = ";";
        $divide = explode($separator, $read);
        echo $divide[0];    
        $fixed_text_1 = $divide[0];
        echo "<br>";
        echo $divide[1];
        $checkbox1 = $divide[1];
        echo "<br>";
    
        fclose($myfile);
    ?>
    <!DOCTYPE HTML>
    <html lang="it">
        <head>
            <title>Esempio</title>
    
        </head>
        <body> <font size="3" face="Verdana">
            <form action="index.php" method="post">
                <div style="overflow-x: auto;">
                    <table>
                        <tr>
                            <th>Table</th>        
                        </tr>
                        <tr>
                            <td>Fixed text</td>
                            <td>
                                <input type="checkbox" name="fixed_text_1" value="1" <?php if($fixed_text_1 == "1") echo "checked"; ?>> Example 1
                            </td>
                        </tr>
                        <tr>
                            <td>Toggle switch 1</td>
                            <td>
                                <label class="toggle">
                                    <input type="checkbox" name="checkbox1" <?php if($checkbox1 == "1") echo "checked"; ?>>
                                    <span class="labels" data-on="ON" data-off="OFF"></span>
                                </label>
                            </td>
                        </tr>
                        <tr>
                            <td>Submit data</td>
                            <td> 
                                <input class="favorite styled" type="submit" name="confirm" value="Enter data">
                            </td>
                        </tr>
                    </table>
                </div>
            </form>
        </body>
    </html>
    
    <?php
        if(isset($_POST["confirm"])){
            // echo "<br><br>--- Preview Enter Data ---<br><br>";
            if(isset($_POST["fixed_text_1"])){
                $fixed_text_1 = "1";
                // echo $fixed_text_1;
                // echo "<br>";
            } else {
                $fixed_text_1 = "0";
                // echo $fixed_text_1;
                // echo "<br>";
            }
            if(isset($_POST['checkbox1'])){
                $checkbx1 = "1";
                // echo $checkbox1;
                // echo "<br>";
            } else {
                $checkbx1 = "0";
                // echo $checkbox1;
                // echo "<br>";
            }
        } else {
            // Non fare nulla  -----------echo"<br>";
        }
        echo "<br><br>--- Enter Data ---<br><br>";
        echo $fixed_text_1."<br>".$checkbx1."<br>";
    ?>
    
    
    <?php
        /*azzera il file*/
        file_put_contents('data.txt', '');
    
        /*stampa a schermo il file*/
        echo "<br><br>--- Preview raw data loaded on data.txt ---<br><br>";
        echo $fixed_text_1."<br>".$checkbx1."<br>";
    
        $fp = fopen('data.txt', 'a');
    
        /*registra il file*/
        $all_data = $fixed_text_1.";".$checkbx1;
    
        fwrite($fp, $all_data,);
        fclose($fp);
    ?>
    Ultima modifica di patdepri; 04-12-2023 a 19:01

Tag per questa discussione

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 © 2025 vBulletin Solutions, Inc. All rights reserved.