come da titolo,
ho trovato la soluzione al mio problema postato ieri, pero' nonostante il form funzioni correttamente (mi segnala i campi non compilati e mi segnala se la mail non è un indirizzo valido) e ricevo la mail, questa ultima è pero' vuota.
questo il mio form:
questo il simplescript.phpcodice:<form name='contactform' action="simplescript.php"> <div class='cform'> <span id='name-err' class='formErrMsg'></span> <label for="name">Nome e cognome</label><input name="name" id="name" type="text" value="" class="req"/> <label for="company">Azienda</label><input name="company" id="company" type="text" value="" class=""/> <span id='electronicaddress-err' class='formErrMsg'></span> <label for="electronicaddress">Email</label><input name="electronicaddress" id="electronicaddress" type="text" value="" class="req validemail"/> <label for="phone">Telefono</label><input name="phone" id="phone" type="text" value=""/> <label for"messagge">Messaggio</label><textarea name='message' id='message' class='req'></textarea> <input type='button' onClick="sendForm();" name='sendbutton' id='sendbutton' value='Invia'> </div> </form>
nell'html della mia pagina contatti ho un paio di javascript, uno per il "focus" sui campi e questocodice:$subject = 'Informazioni dal sito'; // Subject of email sent to you. $emailadd = 'miamail@mioprovider.'; // Your email address. This is where the form information will be sent. $url = 'http://www.miosito.com/miapagina.htm'; // Where to redirect after form is processed. $req = '1'; // Makes all fields required. If set to '1' no field can not be empty. If set to '0' any or all fields can be empty. // --------------------------Do not edit below this line-------------------------- $text = "Results from form:\n\n"; $space = ' '; $line = ' '; foreach ($_POST as $key => $value) { if ($req == '1') { if ($value == '') {echo "$key is empty";die;} } $j = strlen($key); if ($j >= 20) {echo "Name of form element $key cannot be longer than 20 characters";die;} $j = 20 - $j; for ($i = 1; $i <= $j; $i++) {$space .= ' ';} $value = str_replace('\n', "$line", $value); $conc = "{$key}:$space{$value}$line"; $text .= $conc; $space = ' '; } mail($emailadd, $subject, $text, 'From: '.$emailadd.''); echo '<META HTTP-EQUIV=Refresh CONTENT="0; URL='.$url.'">'; ?>
codice:var sending = 0; function sendForm(){ if( validateForm(document.contactform) && sending == 0){ document.getElementById('sendbutton').value = 'Attendere...'; sending = 1; document.contactform.submit(); } }

Rispondi quotando