Visualizzazione risultati 1 fino 14 di 14

Discussione: pannello di moderazione

  1. #1
    Guest

    Predefinito pannello di moderazione

    volevo creare un pannello di moderazione per il mio guestbook in php (il guestbook salva tutti i post in un file txt) allora ho creato questo script

    <?
    $fd=fopen("post.txt", "r");
    while (!feof ($fd)) {
    $buffer = fgets($fd);
    fclose($fd);
    $post = "<form>
    <textarea name=\"file\" rows=\"5\" type=\"text\" value=\"" . $buffer . "\"></textarea>
    <br>
    <input type=\"submit\" name=\"submit\" value=\"Modera\">
    </form>";
    echo $post;
    ?>

    per il momento dovrebbe solo visualizzare un form con il contenuto del file post.txt solo che non funziona e dà questo errore :
    Parse error: parse error, unexpected $ in /membri2/amehomepage/guestbook/mod.php on line 27

    ma alla linea 27 c'è solo il tag </html> come mai?

  2. #2
    Guest

    Predefinito

    controlla le righe prima della 27 magari hai saltato qualche ;

  3. #3
    Guest

    Predefinito

    a me non sembra... ho ricontrollato anche adesso...

  4. #4
    Guest

    Predefinito

    sto facendo uno script in php e mi è successo anche a me era xke nn avevo chiuso una parentesi }

  5. #5
    Guest

    Predefinito

    in effetti ho notato adesso che non ho chiuso il while.... adesso provo



    EDIT: ho provato e infatti non dà + quell' errore solo che nel form non viene scritto il contenuto del file... come mai?
    Ultima modifica di AmeHomePage : 29-08-2005 alle ore 12.00.01

  6. #6
    Guest

    Predefinito

    prova con fread al posto di fgets

  7. #7
    Guest

    Predefinito

    non funzona.... con fread mi dà questo errore

    Fatal error: Maximum execution time of 15 seconds exceeded in /membri2/amehomepage/guestbook/mod.php on line 16

    come mai? Come posso fare a far visualizzare nel form il contenuto del file post.txt?

    PS adesso il codice è così:
    <html>
    <head>
    <title>
    GuestBook
    </title>
    </head>
    <?require "../stile.php";?>
    <center>
    <h1>Guestbook moderazione</h1>
    <?require "../barra.php";?>
    <br>
    <?
    $fd=fopen("post.txt", "r");
    $b = readfile(post.txt);
    while (!feof ($fd)) {
    $buffer = fread($fd, $b);}
    fclose($fd);
    $post = "<form>
    <textarea name=\"file\" rows=\"5\" type=\"text\" value=\"" . $buffer . "\"></textarea>
    <br>
    <input type=\"submit\" name=\"submit\" value=\"Modera\">
    </form>";
    echo $post;
    ?>
    </b>
    </center>
    </body>
    </html>
    Edit: Ho provato a far scrivere su un file il codice che in teoria dovrebbe stampare nella pag html ed è risultato questo:
    <form>
    <textarea name="file" rows="5" value="<FONT COLOR=RED>Dandelion</FONT>carino il guestbook...<BR><BR>" type="text"></textarea>
    <br>
    <input type="submit" name="submit" value="Modera">
    </form>
    dovrebbe essere giusto no?

    Riedit ho provato anche a modificare la posizione di qualcosa ma non cambia niente...
    Ultima modifica di AmeHomePage : 31-08-2005 alle ore 13.29.38

  8. #8
    Guest

    Predefinito

    scusa fare qualcosa del genere non è più semplice:
    Codice HTML:
    <form action="script.php" method="post">
     <textarea name="file" rows="5" type="text">
      <?php include("post.txt"); ?>
     </textarea>
    <input type="submit" name="submit" value="Modera">
    </form>
    Quindi nella pagina script.php ti scrivi il codice per modificare il file post.txt

    In teoria dovrebbe funzionare, prova un po

  9. #9
    Guest

    Predefinito

    <html>
    <head>
    <title>
    GuestBook
    </title>
    </head>
    <?require "../stile.php";?>
    <center>
    <h1>Guestbook moderazione</h1>
    <?require "../barra.php";?>
    <br>
    <?
    $fd=fopen("post.txt", "r");
    while (!feof ($fd)) {
    $buffer = fread($fd);}
    fclose($fd);
    $post = "<form>
    <textarea name=\"file\" rows=\"5\" type=\"text\" value=\"" . $buffer . "\"></textarea>
    <br>
    <input type=\"submit\" name=\"submit\" value=\"Modera\">
    </form>";
    echo $post;
    ?>
    </b>
    </center>
    </body>
    </html>


    prova cosi

  10. #10
    Guest

    Predefinito

    così ho già provato... adesso xò non capisco un' altra cosa (mi sento proprio negato uff...) adesso il codice è così (pensando che funzionasse l' ho postato pure nel topic sui file txt)
    Codice:
    <html>
    <head>
    <title>
    GuestBook
    </title>
    </head>
    <?require "../stile.php";?>
    <center>
    <h1>Guestbook moderazione</h1>
    <?require "../barra.php";?>
    <br>
    <form action="mod.php" method="post">  
    <textarea name="file" rows="50" cols="100">  
    <?php include("post.txt"); ?>  
    </textarea> 
    <br>
    <input type="submit" name="submit" value="Modera"> 
    </form>
    <? 
    $fp=fopen(post.txt, w);
    $contenuto=$_POST['file'];
    fputs($fp, $contenuto);
    fclose($fp);
    
    $fd=fopen(post.txt, a);
    fputs($fd, $contenuto);
    fclose($fd);
    ?>
    </b>
    </center>
    </body>
    </html>
    Solo che non sovrascrive il file post.txt ma lo lascia intatto... come mai? non ha senso! (la prima volta ha funzionato poi ho cambiato il nome del file e non è più andato in nessun modo)
    Ultima modifica di AmeHomePage : 01-09-2005 alle ore 19.30.29

  11. #11
    Guest

    Predefinito

    prova a scrivere sul file in modalità "w" o "w+" al posto di "a", visto che in modalità "a" scrivi alla fine del file. In modalità "w" invece cancelli prima il contenuto del file e lo sovrascrivi con quello contenuto nella textarea

  12. #12
    Guest

    Predefinito

    Ci ho già provato.... (anzi all' inizio il codice l' avevo pensato in modalità w poi visto che non funzionava ho scritto a)

  13. #13
    Guest

    Predefinito

    si ma con la modalità "a" non potrai mai sovrascrivere il file

  14. #14
    Guest

    Predefinito

    Cmq non funzionava neanche con la modalità w

Regole di scrittura

  • Non puoi creare nuove discussioni
  • Non puoi rispondere ai messaggi
  • Non puoi inserire allegati.
  • Non puoi modificare i tuoi messaggi
  •