Pagina 1 di 2 1 2 ultimoultimo
Visualizzazione dei risultati da 1 a 10 su 11
  1. #1
    Utente di HTML.it
    Registrato dal
    Apr 2010
    Messaggi
    272

    Php non prende dati da un form con checkbox

    Allora, ho un generatore che compilando un form prende i campi e crea una pagina dentro il mio sito.

    Tutto va perfettamente tranne il fatto che i checkbox prensenti nel form non li prende

    Il form (index.php):
    Codice PHP:
    <form action="dati.php" method="POST">
    <
    table cellpadding="2" cellspacing="0" align="center" width="500" border="0">
                 <
    tr>
                          <
    td width="100">[b]Nome file:[/b]</td>
                          <
    td><input type="text" name="nome" style="width: 100%;"></td>
                 </
    tr>
                 <
    tr>
                          <
    td>Titolo:</td>
                          <
    td><input type="text" name="title" style="width: 100%;"></td>
                 </
    tr>
                 <
    tr>
                          <
    td>Scritte:</td>
                          <
    td><input type="text" name="scritte" style="width: 100%;"></td>
                 </
    tr>
                 <
    tr>
                          <
    td>Download:</td>
                          <
    td><input type="text" name="download" style="width: 100%;"></td>
                 </
    tr>
                 <
    tr>
                          <
    td>Scansione:</td>
                          <
    td><input type="text" name="scansione" style="width: 100%;"></td>
                 </
    tr>
                 <
    tr>
                          <
    td>Screen:</td>
                          <
    td><input type="text" name="screen" style="width: 100%;"></td>
                 </
    tr>
                 <
    tr>
                          <
    td>Testato su:</td>
                          <
    td><!--<input type="text" name="test" style="width: 100%;">
    -->
                             <
    table>
                             <
    tr><td width="50%"><input name="categoria[]" type="checkbox" value="Win XP 32bit">Win XP 32bit</td>
                                 <
    td width="50%"><input name="categoria[]" type="checkbox" value="Win XP 64bit">Win XP 64bit</td></tr>
                                 <
    tr><td width="50%"><input name="categoria[]" type="checkbox" value="Win Vista 32bit">Win Vista 32bit</td>
                                 <
    td width="50%"><input name="categoria[]" type="checkbox" value="Win Vista 64bit">Win Vista 64bit</td></tr>
                                 <
    tr><td width="50%"><input name="categoria[]" type="checkbox" value="Win 7 (Seven) 32bit">Win 7 (Seven32bit</td>
                                 <
    td width="50%"><input name="categoria[]" type="checkbox" value="Win 7 (Seven) 64bit">Win 7 (Seven64bit</td></tr>
                                 </
    table>
                         </
    td>
                 </
    tr>
                 <
    tr>
                          <
    td colspan="2" align="center">


    <
    input type="submit" value="Invia!" style="width: 100%;"></td>
                 </
    tr>
    </
    table>
    </
    form



    Il php (dati.php)
    Codice PHP:
    <?php 
    $nome 
    $_POST['nome'];
    $title $_POST['title'];
    $scritte $_POST['scritte'];
    $download $_POST['download'];
    $scansione $_POST['scansione'];
    $screen $_POST['screen'];
    $check = (isset($_POST['categoria']) AND is_array($_POST['categoria'])) ? $_POST['categoria'] : array();


    // nome del file in cui inserire i testi 
       
    $file "./hacks/".$nome.".html"

    // apre il file in modalità "append", se non esiste lo crea 
       
    $fp fopen($file"a"); 

    // inserisce i valori ricevuti dal form in coda al file 
       
    fputs($fp"<html><head><title>" .$title"</title><style type='text/css'>html, body {font-family: Tahoma, Arial, Helvetica, sans-serif;}</style></head><body>[b]" .$title"[/b]

    .$scritte"

    [b]Download: [/b][url]http://adf.ly/116908/[/url]" 
    .$download"
    [b]Scansione: [/b][url]http://adf.ly/116908/[/url]" 
    .$scansione"
    [b]Screen: [/b]" 
    .$screen"
    [b]Testato su: [/b]" 
    .$check"
    </body></html>"
    );

    // chiude il file 
       
    fclose($fp); 
         
    // Scrive i link
         
    echo "<center>
             [url='./code/"
    .$nome.".html']Vai al File Generato[/url] | 
             [url='index.php']Crea un Nuovo File[/url]
             




                     <iframe src='./code/"
    .$nome.".html' width='1000' height='500'></iframe>
                     </center>"
    ;
    ?>
    HELP!

  2. #2
    Utente di HTML.it L'avatar di bstefano79
    Registrato dal
    Feb 2004
    Messaggi
    2,520
    prova a cambiare tutti i name="categoria[]" in name="categoria"

  3. #3
    cosa stampa questo?

    Codice PHP:
    foreach ($_POST["categoria"] as $check 

    echo 
    $check"
    "
    ;

    http://codecanyon.net/category/all?ref=Manuelandro
    And I bet she told a million people that she'd stay in touch, Well all the little promises they dont mean much,When theres
    memories to be made

  4. #4
    Utente di HTML.it
    Registrato dal
    Apr 2010
    Messaggi
    272
    Originariamente inviato da Manuelandro
    cosa stampa questo?

    Codice PHP:
    foreach ($_POST["categoria"] as $check 

    echo 
    $check"
    "
    ;

    Questo stama: ARRAY


    cmq scusa (sono ignorante di php) come applico il tuo code?

  5. #5
    Originariamente inviato da DjDukio
    Questo stama: ARRAY


    cmq scusa (sono ignorante di php) come applico il tuo code?
    togli per un secondo la riga $check = etc etc e metti questo, così capiamo se l'array è pieno
    http://codecanyon.net/category/all?ref=Manuelandro
    And I bet she told a million people that she'd stay in touch, Well all the little promises they dont mean much,When theres
    memories to be made

  6. #6
    Utente di HTML.it
    Registrato dal
    Apr 2010
    Messaggi
    272
    L'ho messo così:

    Codice PHP:
    <?php 
    $nome 
    $_POST['nome'];
    $title $_POST['title'];
    $scritte $_POST['scritte'];
    $download $_POST['download'];
    $scansione $_POST['scansione'];
    $screen $_POST['screen'];
    foreach (
    $_POST["categoria"] as $check )  
    {  
    echo 
    $check"
    "

    }
    // $check = (isset($_POST['categoria']) AND is_array($_POST['categoria'])) ? $_POST['categoria'] : array();


    // nome del file in cui inserire i testi 
       
    $file "./hacks/".$nome.".html"

    // apre il file in modalità "append", se non esiste lo crea 
       
    $fp fopen($file"a"); 

    // inserisce i valori ricevuti dal form in coda al file 
       
    fputs($fp"<html><head><title>" .$title"</title><style type='text/css'>html, body {font-family: Tahoma, Arial, Helvetica, sans-serif;}</style></head><body>[b]" .$title"[/b]

    .$scritte"

    [b]Download: [/b][url]http://adf.ly/116908/[/url]" 
    .$download"
    [b]Scansione: [/b][url]http://adf.ly/116908/[/url]" 
    .$scansione"
    [b]Screen: [/b]" 
    .$screen"
    [b]Testato su: [/b]" 
    .$check"
    </body></html>"
    );

    // chiude il file 
       
    fclose($fp); 
         
    // Scrive i link
         
    echo "<center>
             [url='./code/"
    .$nome.".html']Vai al File Generato[/url] | 
             [url='index.php']Crea un Nuovo File[/url]
             




                     <iframe src='./code/"
    .$nome.".html' width='1000' height='500'></iframe>
                     </center>"
    ;
    ?>
    e mi scrive correttamente ciò che seleziono


    come faccio xo a far uscire queste cose nel mio code?

  7. #7
    Utente di HTML.it
    Registrato dal
    Apr 2010
    Messaggi
    272
    In pratica quei valori devono andare in:
    Codice PHP:
    // inserisce i valori ricevuti dal form in coda al file  
       
    fputs($fpecc...... 
    dove io attualmente cerco di richiamarli con .$check.

  8. #8
    Utente di HTML.it
    Registrato dal
    Apr 2010
    Messaggi
    272
    Ho provato così:

    Codice PHP:
    // inserisce i valori ricevuti dal form in coda al file 
       
    fputs($fp"
         <html>
         <head>
         <title>" 
    .$title"</title>
         <style type='text/css'>
         html, body {font-family: Tahoma, Arial, Helvetica, sans-serif;}
         </style>
         </head>
         <body>
         [b]" 
    .$title"[/b]


         " 
    .$scritte"


         [b]Download: [/b][url]http://adf.ly/116908/[/url]" 
    .$download"

         [b]Scansione: [/b][url]http://adf.ly/116908/[/url]" 
    .$scansione"

         [b]Screen: [/b]" 
    .$screen"

         [b]Testato su: [/b]" 
    .$check"

         </body>
         </html>"
    ); 
    ma mi stampa solo l'ultima voce selezionata :S

  9. #9
    Utente di HTML.it
    Registrato dal
    Apr 2010
    Messaggi
    272
    pls help!

  10. #10
    Codice PHP:
    <?php 
    $nome 
    $_POST['nome'];
    $title $_POST['title'];
    $scritte $_POST['scritte'];
    $download $_POST['download'];
    $scansione $_POST['scansione'];
    $screen $_POST['screen'];
    $check "";
    foreach (
    $_POST["categoria"] as $val )  
    {  
    $check .= $val." ,"
    }



    // nome del file in cui inserire i testi 
       
    $file "./hacks/".$nome.".html"

    // apre il file in modalità "append", se non esiste lo crea 
       
    $fp fopen($file"a"); 

    // inserisce i valori ricevuti dal form in coda al file 
       
    fputs($fp"<html><head><title>" .$title"</title><style type='text/css'>html, body {font-family: Tahoma, Arial, Helvetica, sans-serif;}</style></head><body>[b]" .$title"[/b]

    .$scritte"

    [b]Download: [/b][url='http://adf.ly/116908/'][url]http://adf.ly/116908/[/url][/url]" 
    .$download"
    [b]Scansione: [/b][url='http://adf.ly/116908/'][url]http://adf.ly/116908/[/url][/url]" 
    .$scansione"
    [b]Screen: [/b]" 
    .$screen"
    [b]Testato su: [/b]" 
    .$check"
    </body></html>"
    );

    // chiude il file 
       
    fclose($fp); 
         
    // Scrive i link
         
    echo "<center>
             [url='./code/"
    .$nome.".html']Vai al File Generato[/url] | 
             [url='index.php']Crea un Nuovo File[/url]
             




                     <iframe src='./code/"
    .$nome.".html' width='1000' height='500'></iframe>
                     </center>"
    ;
    ?>
    http://codecanyon.net/category/all?ref=Manuelandro
    And I bet she told a million people that she'd stay in touch, Well all the little promises they dont mean much,When theres
    memories to be made

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.