Scusa eccolo
Codice PHP:
<?php $your_email ='info@webepc.it';// <<=== update to your email address session_start(); $errors = ''; $name = ''; $visitor_email = ''; $user_message = ''; if(isset($_POST['submit'])) { $name = $_POST['name']; $visitor_email = $_POST['email']; $user_message = $_POST['message']; ///------------Do Validations------------- if(empty($name)||empty($visitor_email)) { $errors .= "\n Nome e Email sono obbligatori."; } if(IsInjected($visitor_email)) { $errors .= "\n indirizzo email non valido!"; } if(empty($_SESSION['6_letters_code'] ) || strcasecmp($_SESSION['6_letters_code'], $_POST['6_letters_code']) != 0) { //Note: the captcha code is compared case insensitively. //if you want case sensitive match, update the check above to // strcmp() $errors .= "\n Il codice captcha non corrisponde!"; } if(empty($errors)) { //send the email $to = $your_email; $subject="modulo dal sito [url]www.webepc.it[/url]"; $from = $your_email; $ip = isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : ''; $body = "A user $name submitted the contact form:\n". "Name: $name\n". "Email: $visitor_email \n". "Message: \n ". "$user_message\n". "IP: $ip\n"; $headers = "da: $from \r\n"; $headers .= "rispondi: $visitor_email \r\n"; mail($to, $subject, $body,$headers); header('Location: thank-you.html'); } } // Function to validate against any email injection attempts function IsInjected($str) { $injections = array('(\n+)', '(\r+)', '(\t+)', '(%0A+)', '(%0D+)', '(%08+)', '(%09+)' ); $inject = join('|', $injections); $inject = "/$inject/i"; if(preg_match($inject,$str)) { return true; } else { return false; } } ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title>Contact Us</title> <style> label,a, body { font-family : Arial, Helvetica, sans-serif; font-size : 12px; } .err { font-family : Verdana, Helvetica, sans-serif; font-size : 12px; color: red; } </style> <script language="JavaScript" src="scripts/gen_validatorv31.js" type="text/javascript"></script> </head> <body> <?php if(!empty($errors)){ echo "<p class='err'>".nl2br($errors)."</p>"; } ?> <div id='contact_form_errorloc' class='err'></div> <form method="POST" name="contact_form" action="<?php echo htmlentities($_SERVER['PHP_SELF']); ?>">
<label for='name'>Nome e Cognome: </label>
<input type="text" name="name" value='<?php echo htmlentities($name) ?>'> </p>
<label for='email'>Email: </label>
<input type="text" name="email" value='<?php echo htmlentities($visitor_email) ?>'> </p>
<label for='message'>Messaggio:</label>
<textarea name="message" rows=8 cols=30><?php echo htmlentities($user_message) ?></textarea> </p>
[img]captcha_code_file.php?rand=<?php echo rand(); ?>[/img]
<label for='message'>Inserisci il codice qua:</label>
<input id="6_letters_code" name="6_letters_code" type="text">
[size="1"]Non riesci a leggere l'immagine? clicca [url='javascript: refreshCaptcha();']qui[/url] per aggiornarla[/size] </p> <input type="submit" value="invia" name='submit'> </form> <script language="JavaScript"> // Code for validating the form // Visit [url]http://www.javascript-coder.com/html-form/javascript-form-validation.phtml[/url] // for details var frmvalidator = new Validator("contact_form"); //remove the following two lines if you like error message box popups frmvalidator.EnableOnPageErrorDisplaySingleBox(); frmvalidator.EnableMsgsTogether(); frmvalidator.addValidation("name","req","Please provide your name"); frmvalidator.addValidation("email","req","Please provide your email"); frmvalidator.addValidation("email","email","Please enter a valid email address"); </script> <script language='JavaScript' type='text/javascript'> function refreshCaptcha() { var img = document.images['captchaimg']; img.src = img.src.substring(0,img.src.lastIndexOf("?"))+"?rand="+Math.random()*1000; } </script> <noscript> Code from the [url='http://www.html-form-guide.com/contact-form/html-contact-form-captcha.html']php contact form[/url] article. </noscript> </body> </html>