Visualizzazione dei risultati da 1 a 2 su 2

Discussione: Problema con file .txt

  1. #1

    Problema con file .txt

    Ciao a tutti
    Sono nuovo del forum...
    Da una sttimana mi sto scervellando (essendo alle prime armi con php) per creare un sistema che potesse controllare il mio arduino...
    Ho pensato di memorizzare lo stato dei pin dell'arduino su dei file .txt
    e poi fare leggere alla pagina lo stato...
    Ma veniamo al punto...
    Il mio problema è che 2.php non mi salva lo stato sui file .txt...
    index.php:
    codice:
    <?php
    $statusg2 = fopen("stato2.txt", "r");
    if(!$statusg2) die ("Errore nella operaione con il file");
    $data2 = fread($statusg2, 2);
    if ($data2 == ON) {
    echo'<a href="http://salvatore.passaro.info/controllo/2.php/?status1=2off&stato=2off">';
     echo '[img]on.png[/img]'; 
     } else {
     echo'<a href="http://salvatore.passaro.info/controllo/2.php/?status1=ON&stato=2on">';
     echo '[img]off.png[/img]'; 
     }
    ?>
    <?php
    $statusg3 = fopen("stato3.txt", "r");
    if(!$statusg3) die ("Errore nella operaione con il file");
    $data3 = fread($statusg3, 2);
    if ($data3 == ON) {
    echo'<a href="http://salvatore.passaro.info/controllo/2.php/?status2=3off&stato=3off">';
     echo '[img]on.png[/img]'; 
     } else {
     echo'<a href="http://salvatore.passaro.info/controllo/2.php/?status2=ON&stato=3on">';
     echo '[img]off.png[/img]'; 
     }
    ?>
    <?php
    $statusg4 = fopen("stato4.txt", "r");
    if(!$statusg4) die ("Errore nella operaione con il file");
    $data4 = fread($statusg4, 2);
    if ($data4 == ON) {
    echo'<a href="http://salvatore.passaro.info/controllo/2.php/?status3=4off&stato=4off">';
     echo '[img]on.png[/img]'; 
     } else {
     echo'<a href="http://salvatore.passaro.info/controllo/2.php/?status3=ON&stato=4on">';
     echo '[img]off.png[/img]'; 
     }
    ?>
    <?php
    $statusg5 = fopen("stato5.txt", "r");
    if(!$statusg5) die ("Errore nella operaione con il file");
    $data5 = fread($statusg5, 2);
    if ($data5 == ON) {
    echo'<a href="http://salvatore.passaro.info/controllo/2.php/?status4=5off&stato=5off">';
     echo '[img]on.png[/img]'; 
     } else {
     echo'<a href="http://salvatore.passaro.info/controllo/2.php/?pin=status4=ON&stato=5on">';
     echo '[img]off.png[/img]'; 
     }
    ?>
    <?php
    $statusg6 = fopen("stato6.txt", "r");
    if(!$statusg6) die ("Errore nella operaione con il file");
    $data6 = fread($statusg6, 2);
    if ($data6 == ON) {
    echo'<a href="http://salvatore.passaro.info/controllo/2.php/?status5=6off&stato=6off">';
     echo '[img]on.png[/img]'; 
     } else {
     echo'<a href="http://salvatore.passaro.info/controllo/2.php/?status5=ON&stato=6on">';
     echo '[img]off.png[/img]'; 
     }
    ?>
    Ringrazio in anticipo
    Salvo

    2.php:
    codice:
    <?php
    $stato = $_GET['stato'];
    $status1 = $_GET['status'];
    $a = fopen("stato1.txt", "w");
    if(!$a) die ("Errore nella operaione con il file1");
    fwrite($a, $status1);
    $status2 = $_GET['status1'];
    $b = fopen("stato2.txt", "w");
    if(!$b) die ("Errore nella operaione con il file2");
    fwrite($b, $status2);
    $status3 = $_GET['status2'];
    $c = fopen("stato3.txt", "w");
    if(!$c) die ("Errore nella operaione con il file3");
    fwrite($c, $status3);
    $status4 = $_GET['status3'];
    $d = fopen("stato4.txt", "w");
    if(!$d) die ("Errore nella operaione con il file4");
    fwrite($d, $status4);
    $status5 = $_GET['status5'];
    $e = fopen("stato5.txt", "w");
    if(!$e) die ("Errore nella operaione con il file5");
    fwrite($e, $status5);
    $status6 = $_GET['status5'];
    $f = fopen("stato6.txt", "w");
    if(!$f) die ("Errore nella operaione con il file6");
    fwrite($f, $status6);
    @header("Location: http://salvatore16.dyndns-ip.com/?$stato");
    ?>

  2. #2
    Ho risolto
    Grazie lo stesso

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.