Form: checkbox, radio..
-
salve a tutti! ho girovagato per il sito e ho notato che è molto ben fatto, complimentz!! premesso che non so praticamente nulla di php, "l'ho appena conosciuto", cercavo aiuto per la creazione di un form.. non mi riesce proprio, sarò negatooo

devo creare un questionario con risposte aperte, si/no, e varie opzioni: fintanto che lavoro con le textarea e gli textinput va tutto bene, ma ho provato ad inserire delle scelte multiple con i checkbox ed altre con i radio.. niente..
premetto che mi serve il<img src="securimage_show.php">per evitare lo spamming.. (captcha)
cercavo di modificare questo codice qui:<?php /* This is the contact form I use on my site Feel free to modify it and use it as a guide to setting up securimage for your site. */ $to = "mail@localhost"; if (!isset($_POST['submit'])) { showForm(); } else { //form submitted $error = 0; if(empty($_POST['name'])) { $error = 1; $errstr[] = "Inserisci il nome"; } if(empty($_POST['eta'])) { $error = 1; $errstr[] = "inserisci l'età"; } if(!preg_match("/^(?:[\w\d]+\.?)+@(?:(?:[\w\d]\-?)+\.)+\w{2,4}$/", $_POST['email'])) { $error = 1; $errstr[] = "Please enter a valid email address"; } if(empty($_POST['answer01']) || preg_match("/^enter your message here$/i", $_POST['answer01'])) { $error = 1; $errstr[] = "Please answer question 1 or write '-'"; } if(empty($_POST['imagetext'])) { $error = 1; $errstr[] = "Please validate the image code"; } else { include "securimage.php"; $img = new securimage(); $valid = $img->check($_POST['imagetext']); if(!$valid) { $error = 1; $errstr[] = "The code you entered was incorrect"; } } if ($error == 1) { echo "<center>\n<font style=\"color: #FF0000\">\n"; foreach($errstr as $err) { echo "<li> " . $err . "</li>\n"; } echo "</font>\n</center>\n<br />\n\n"; showForm(); } else { @mail($to, "Risultati - " . $_POST['lang'] . "", "Compilato: " . date("r") . ", da: " . $_POST['name'] . ", eMail: " . $_POST['email'] . ", Età: " . $_POST['eta'] . "\n sent the following message.\nReason " . "\n\n" . stripslashes($_POST['message']), "From: " . $_POST['email']); echo "<p>\nThanks for contacting me. I'll try to get back to you as soon as I can. Thanks for visiting my website. If I don't get back to you within one week, please fill out the form again.<br /><br />" ."tell a friend"; } } //else submitted function showForm() { $_POST['message'] = @htmlspecialchars(@$_POST['message']); echo <<<EOD <form method="POST"><input name="lang" type="hidden" value="Italiano"> <h2>Name: <input type="text" name="name" value="{$_POST['name']}" /> | Età: <input type="text" name="eta" size="2" maxlength="2" value="{$_POST['eta']}" /></h2><br /> <h2>Email Address: <input type="text" name="email" value="{$_POST['email']}" /></h2><br /> <h2>Domanda1</h2> <p>testo della domanda</p> <p> </p> <textarea name="answer01" rows="6" cols="70">{$_POST['answer01']}</textarea><br /><br /> <center><img src="securimage_show.php"><br /><br /> Enter the text above<br /><br /> <input style="text-transform: uppercase;" type="text" name="imagetext" /><br /><br /> <span class="button"><input type="submit" name="submit" /></span></center> </form> EOD; } ?>la mia intenzione era quella di inserire dei checkbox (M/F) e dei radio ma non so come ficcarli dentro.. avevo provato, ma non riesco a far apparire il valore scelto.. esempio per il checkbox m/f: io metto le due opzioni, ma quando faccio invia 1) non mi controlla che sia pieno o vuoto 2) non mi dice il risultato..

e già questo è un problema..
poi ce n'è un'altro.. vorrei sapere se è possibile "printare" le -avere un'anteprima delle- risposte prima che mi invii l'email, e che l'indirizzo email
$_POST['email']venga compreso nel
$to. = "";avevo già notato che se ne era discusso qui più o meno (per i radio), ma non mi serve mysql, devo semplicemente avere un'anteprima dell'email che invierà con le risposte al questionario..
come fare tutto ciò?? magari è una banalità.. grazie in anticipo

ps molti link nel sito rimandano al vecchio forum http://giorgiotave.mastertopforum.com/
-
-
Ciao! Sembra che tu sia interessato a questa conversazione, ma non hai ancora un account.
Stanco di dover scorrere gli stessi post a ogni visita? Quando registri un account, tornerai sempre esattamente dove eri rimasto e potrai scegliere di essere avvisato delle nuove risposte (tramite email o notifica push). Potrai anche salvare segnalibri e votare i post per mostrare il tuo apprezzamento agli altri membri della comunità.
Con il tuo contributo, questo post potrebbe essere ancora migliore 💗
Registrati Accedi