Pagina 1 di 3 1 2 3 ultimoultimo
Visualizzazione dei risultati da 1 a 10 su 22
  1. #1

    form con campi obbligatori

    Ciao sono alla ricerca di un form con campi obbligatori che raccoglie dati e li invia ad un indirizzo e-mail.
    Mi occorre però un qualcosa di già precostituito da intsllare tale e quale.

    Sapete indicarmi un link dove posso scaricare qualcosa del genere?

    Grazie

  2. #2

  3. #3

    re

    Ciao maje a me serve un form che abbia anche
    la casella di spunta obbligatoria per l'accettazione delle legge
    sulla privacy.

    Esiste qualcosa di già precostituito da scaricare ed installare? Ti dico questo
    in quanto non sono un programmatore quindi non sono ingrado più di tanto
    di smanettare con il php.

    Grazie

  4. #4
    mmm, usi qualche CMS? se non utilizzi un CMS mi sa qualche riga di codice in php la dovrai scrivere

  5. #5

    re

    ciao maje,

    non nel sito in questione non sto usando un CMS ma semplici pagine HTML. A dire il vero sono riuscito a trovare un semplice form con campi obbligatori e funziona correttamente. Soltanto che ora ci dovrei integrare alla fine il pulsante di spunta per l'acettazione dei dati personali e della privacy. Ovviamente questa operazione non la so fare. Ecco xchè cercavo un qualcosa di precostituito. Praticamente i campi che mi interessano sono:

    nome e cognome

    indirizzo e-mail

    numero di telefono

    richiesta

    casella da spuntare (anche questa obbligatoria) per accettazione privacy.

    Come vedi è qualcosa di molto semplice.

    Mi puoi aiutare in qualche modo?

    Grazi

  6. #6
    innazitutto quello che ti serve è un campo checkbox:

    http://www.w3schools.com/html/html_forms.asp

    su cui a fianco metti un link che può visualizzare in qualche modo la privacy (es. popup). Fatto questo devi controllare il valore della checkbox, per verificare che sia stato "checkato": sicuramente devi farlo lato server (con PHP, prendendo il post della checkbox) e, volendo, anche lato client (javascript). Magari posta il codice del form, sia quello html che php, hai già qualcosa giusto?

  7. #7
    ciao,

    io penso che sarebbe preferibile validarli via client tramite il javascript.

    Ti posto di seguito il codice
    codice:
    <form name="contactformlite" method="post" action="lite_process.php" onsubmit="return validate.check(this)"> 	<table width="400px" class="cflite"> 	<tr> 	 <td colspan="2"> 	  <p style="text-align:center">I campi con <span class="required_star"> * </span> sono obbligatori.</p> 	 </td> 	</tr> 	<tr> 	 <td valign="top" class="cflite_td"> 	  <label for="Full_Name" class="required">Nome e Cognome <span class="required_star"> * </span></label> 	 </td> 	 <td valign="top" class="cflite_td"> 	  <input type="text" name="Full_Name" id="Full_Name" maxlength="80" style="width:250px"> 	 </td> 	</tr> 	<tr> 	 <td valign="top" class="cflite_td"> 	  <label for="Email_Address" class="required">Indirizzo Email<span class="required_star"> * </span></label> 	 </td> 	 <td valign="top" class="cflite_td"> 	  <input type="text" name="Email_Address" id="Email_Address" maxlength="100" style="width:250px"> 	 </td> 	</tr> 	<tr> 	 <td valign="top" class="cflite_td"> 	  <label for="Telephone_Number" class="not-required">Numero di telefono </label> 	 </td> 	 <td valign="top" class="cflite_td"> 	  <input type="text" name="Telephone_Number" id="Telephone_Number" maxlength="100" style="width:250px"> 	 </td> 	</tr> 	<tr> 	 <td valign="top" class="cflite_td"> 	  <label for="Your_Message" class="required">Richiesta<span class="required_star"> * </span></label> 	 </td> 	 <td valign="top" class="cflite_td"> 	  <textarea style="width:250px;height:120px" name="Your_Message" id="Your_Message" maxlength="2000"></textarea> 	 </td> 	</tr> 	<tr> 	 <td valign="top" class="cflite_td"> 	  <label for="Accettazione" class="required">Accettazione<span class="required_star"> * </span></label> 	 </td> 	 <td valign="top" class="cflite_td"> 	  <input name="Accettazione" type="checkbox" id="Accettazione" value="checkbox" /> 	 </td> 	</tr> 	<tr> 	 <td colspan="2" style="text-align:center"  class="cflite_td"> 	  <input type="submit" value="Invia"> 	  
    
     	   	  <div style="font-size:0.9em"></div> 	  
    
     	 </td> 	</tr> 	</table> 	</form>

  8. #8
    quello che ti ho appena postato è il codice del form della pagina HTML

    ad inizio della stessa pagina c'è lo script per la validazione:

    <script src="lite_validation.js"></script>
    <script>
    required.add('Full_Name','NOT_EMPTY','Full Name');
    required.add('Email_Address','EMAIL','Email Address');
    required.add('Your_Message','NOT_EMPTY','Your Message')
    required.add('Accettazione','NOT_EMPTY','Accettazi one')
    </script>

  9. #9

    re

    quì invece ti posto il codice della pagina php che processa i dati provenienti dal form e li invia ad un indirizzo e-mail.
    codice:
    <?php // URL: www.freecontactform.com // Version: FreeContactForm Lite V1.2 // Copyright (c) 2010 Stuart Cochrane <stuartc1@gmail.com> // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. if(isset($_POST['Email_Address'])) { 	 	include 'lite_settings.php'; 	 	function died($error) { 		echo "Sorry, but there were error(s) found with the form you submitted. "; 		echo "These errors appear below.
    
    "; 		echo $error."
    
    "; 		echo "Please go back and fix these errors.
    
    "; 		die(); 	} 	 	if(!isset($_POST['Full_Name']) || 		!isset($_POST['Email_Address']) || 		!isset($_POST['Telephone_Number']) || 		!isset($_POST['Your_Message'])) { 		died('We are sorry, but there appears to be a problem with the form you submitted.');		 	} 	 	$full_name = $_POST['Full_Name']; // required 	$email_from = $_POST['Email_Address']; // required 	$telephone = $_POST['Telephone_Number']; // not required 	$comments = $_POST['Your_Message']; // required 	 	$error_message = ""; 	$email_exp = "^[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$";   if(!eregi($email_exp,$email_from)) {   	$error_message .= 'The Email Address you entered does not appear to be valid.
    ';   }   if(strlen($full_name) < 2) {   	$error_message .= 'Your Name does not appear to be valid.
    ';   }   if(strlen($comments) < 2) {   	$error_message .= 'The Comments you entered do not appear to be valid.
    ';   }      if(strlen($error_message) > 0) {   	died($error_message);   } 	$email_message = "Richiesta informazioni proveniente dal sito internet.\r\n"; 	 	function clean_string($string) { 	  $bad = array("content-type","bcc:","to:","cc:","href"); 	  return str_replace($bad,"",$string); 	} 	 	$email_message .= "Nome Cognome: ".clean_string($full_name)."\r\n"; 	$email_message .= "Email: ".clean_string($email_from)."\r\n"; 	$email_message .= "Numero telefonico: ".clean_string($telephone)."\r\n"; 	$email_message .= "Richiesta: ".clean_string($comments)."\r\n"; 	 $headers = 'From: '.$email_from."\r\n". 'Reply-To: '.$email_from."\r\n" . 'X-Mailer: PHP/' . phpversion(); @mail($email_to, $email_subject, $email_message, $headers); header("Location: $thankyou"); ?> <script>location.replace('<?php echo $thankyou;?>')</script> <? } ?>

  10. #10
    per la validazione lato client potresti usare una cosa del genere:

    codice:
    <script type="text/javascript">
    <!--
    
    function validate_form ( )
    {
        valid = true;
    
        if ( !document.contactformlite.Accettazione.checked )
        {
            alert ( "Accetta i termini per la privacy" );
            valid = false;
        }
    
        return valid;
    }
    
    //-->
    </script>
    
    <form name="contactformlite" method="post" action="lite_process.php" onsubmit="return validate_form();" >
    <table width="400px" class="cflite">
    	<tr>
    		<td colspan="2">
    		<p style="text-align: center">I campi con <span class="required_star">
    		* </span> sono obbligatori.</p>
    		</td>
    	</tr>
    	<tr>
    		<td valign="top" class="cflite_td"><label for="Full_Name"
    			class="required">Nome e Cognome <span class="required_star"> * </span></label>
    		</td>
    		<td valign="top" class="cflite_td"><input type="text" name="Full_Name"
    			id="Full_Name" maxlength="80" style="width: 250px"></td>
    	</tr>
    	<tr>
    		<td valign="top" class="cflite_td"><label for="Email_Address"
    			class="required">Indirizzo Email<span class="required_star"> * </span></label>
    		</td>
    		<td valign="top" class="cflite_td"><input type="text"
    			name="Email_Address" id="Email_Address" maxlength="100"
    			style="width: 250px"></td>
    	</tr>
    	<tr>
    		<td valign="top" class="cflite_td"><label for="Telephone_Number"
    			class="not-required">Numero di telefono </label></td>
    		<td valign="top" class="cflite_td"><input type="text"
    			name="Telephone_Number" id="Telephone_Number" maxlength="100"
    			style="width: 250px"></td>
    	</tr>
    	<tr>
    		<td valign="top" class="cflite_td"><label for="Your_Message"
    			class="required">Richiesta<span class="required_star"> * </span></label>
    		</td>
    		<td valign="top" class="cflite_td"><textarea
    			style="width: 250px; height: 120px" name="Your_Message"
    			id="Your_Message" maxlength="2000"></textarea></td>
    	</tr>
    	<tr>
    		<td valign="top" class="cflite_td"><label for="Accettazione"
    			class="required">Accettazione<span class="required_star"> * </span></label>
    		</td>
    		<td valign="top" class="cflite_td"><input name="Accettazione"
    			type="checkbox" id="Accettazione" value="checkbox" /></td>
    	</tr>
    	<tr>
    		<td colspan="2" style="text-align: center" class="cflite_td">
    		<input type="submit" value="Invia"> 
    
    		
    
    		
    		<div style="font-size: 0.9em"></div>
    		
    
    		
    
    		</td>
    	</tr>
    </table>
    </form>
    altrimenti dovresti postare lite_validation.js per intervenire lì. Comunque la validazione lato server e' MOLTO PIU' IMPORTANTE, perchè quella client è facilmente bypassabile.

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.