Codice PHP:
<?php
$your_email ='vcarpini@gmail.com';// <<=== update to your email address
session_start();
$errors = '';
$name = '';
$lastname = '';
$visitor_email = '';
$company = '';
$website = '';
$address = '';
$country = '';
$phone = '';
$state = '';
$subject = '';
$user_message = '';
if(isset($_POST['submit']))
{
$name = $_POST['name'];
$lastname = $_POST['lastname'];
$visitor_email = $_POST['email'];
$company = $_POST['company'];
$website = $_POST['website'];
$address = $_POST['address'];
$country = $_POST['country'];
$phone = $_POST['phone'];
$state = $_POST['state'];
$subject = $_POST['subject'];
$user_message = $_POST['message'];
///------------Do Validations-------------
if(empty($name)||empty($visitor_email))
{
$errors .= "\n Name and Email are required fields. ";
}
if(IsInjected($visitor_email))
{
$errors .= "\n Bad email value!";
}
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 The captcha code does not match!";
}
if(empty($errors))
{
//send the email
$to = $your_email;
$subject="New form submission";
$from = $your_email;
$ip = isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : '';
$body = "A user $name submitted the contact form:\n".
"Name: $name\n".
"lastname: $lastname\n".
"Eemail: $visitor_email\n".
"company: $company\n".
"website: $website\n".
"address: $address\n".
"country: $country\n".
"phone: $phone\n".
"state: $state\n".
"subject: $subject\n".
"Message: \n ".
"$user_message\n".
"IP: $ip\n";
$headers = "From: $from \r\n";
$headers .= "Reply-To: $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 XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>AdesignS21</title>
<meta name="author" content=" " />
<meta name="keywords" content="" />
<meta name="description" content="" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="stylesheet" href="css/style.css" type="text/css" />
<link rel="stylesheet" href="css/galleriffic-2.css" type="text/css" />
<link rel="shortcut icon" type="image/x-icon" href="html-contact-form-captcha/favicon.ico" />
<link rel="icon" type="image/x-icon" href="html-contact-form-captcha/favicon.ico" />
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript" src="js/verticalscroller.js"></script>
<script type="text/javascript" src="js/jquery.galleriffic.js"></script>
<script type="text/javascript" src="js/jquery.opacityrollover.js"></script>
<script language="JavaScript" src="js/gen_validatorv31.js" type="text/javascript"></script>
<script type="text/javascript" src="html-contact-form-captcha/js/noscript.js"></script>
</head>
<body>
<div class="container">
<div class="logo" id="top"> [url="html-contact-form-captcha/index.html"][img]images/logo.gif[/img][/url]
</div>
<script type="text/javascript" src="http://www.yourinspirationweb.com/WhiteFolio/swfobject.js"></script>
<script type="text/javascript">
var s1 = new SWFObject("imagerotator.swf","rotator","940","368","7");
s1.addVariable("file","madrid.xml");
s1.addVariable("width","940");
s1.addVariable("height","368");
s1.addVariable("transition","blocks");
s1.addVariable("shownavigation","false");
s1.addParam("wmode","opaque");
s1.write("slider");
</script>
<div id="contact">
<div class="TopNavigation">
<ul class="nav">[*] [url="index.html"]Home[/url][*][url="about.html"]About[/url][*][url="products.html"]Products[/url][*][url="interiors.html"]Interiors[/url]
<li class="active">Info[/list]
<div class="social">
[url="#"][img]images/icons/twitter.gif[/img][/url]
[url="#"][img]images/icons/feed.gif[/img][/url]
[url="#"][img]images/icons/mail.gif[/img][/url]
</div>
</div>
<h2>Info e Contatti</h2>
Contattaci quando vuoi per un preventivo, per richiedere qualsiasi informazione sulla nostra
metodologia di lavoro, o anche solo per farci sapere che sei passato di qua. Utilizza il seguente modulo o, se preferisci, uno
recapiti contrassegnati in questa pagina. Ti risponderemo appena possibile!
</p>
<div id="form">
<?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']); ?>">
<fieldset class="info_fieldset">
<div id="note"></div>
<div id="fields">
<label>Your name: *</label><input class="textbox" type="text" name="name" value='<?php echo htmlentities($name) ?>'>
<label>Your last name: *</label><input class="textbox" type="text" name="lastname" value='<?php echo htmlentities($lastname) ?>'>
<label>E-mail: *</label><input class="textbox" type="text" name="visitor_email" value='<?php echo htmlentities($visitor_email) ?>'>
<label>Company:</label><input class="textbox" type="text" name="company" value='<?php echo htmlentities($company) ?>'>
<label>Website:</label><input class="textbox" type="text" name="website" value='<?php echo htmlentities($website) ?>'>
<label>Address: *</label><input class="textbox" type="text" name="address" value='<?php echo htmlentities($address) ?>'>
<label>Country:</label><input class="textbox" type="text" name="country" value='<?php echo htmlentities($country) ?>'>
<label>Phone number: *</label><input class="textbox" type="text" name="phone" value='<?php echo htmlentities($phone) ?>'>
<label>State:</label><input class="textbox" type="text" name="state" value='<?php echo htmlentities($state) ?>'>
<label>Subject:</label><input class="textbox" type="text" name="subject" value='<?php echo htmlentities($subject) ?>'>
<label>Message: *</label><textarea class="textbox2" name="user_message" rows="5" cols="25"><?php echo htmlentities($user_message) ?></textarea>
[img]contact_form/captcha_code_file.php?rand=<?php echo rand(); ?>[/img]
<label for='message'>Enter the code above here :</label>
<input id="6_letters_code" name="6_letters_code" type="text">
[size="1"]Can't read the image? click [url='java-script: refreshCaptcha();']here[/url] to refresh[/size]
</p>
<label> </label><input class="button" type="image" src="images/send.gif" id="submit" value="Send Message" />
</fieldset>
</form>
</div>
<div id ="contactInfo">
Ci puoi trovare qui:
<span class="bolder">
Barberino di Mugello (FI)
Piazza Cavour 18
</span>
</p>
Oppure puoi contattaci attraverso uno dei seguenti social network:
</p>
<span class="bolder">Twitter</span> [Adesigns21]
</p>
<span class="bolder">FaceBook</span> [Adesigns21]
</p>
<span class="bolder">Skype</span> [Adesigns21]
</p>
O, se preferisci, contattaci telefonicamente:
</p>
<p class="bolder">
+39 339/3477843
</p>
Ricordati che puoi richiedere un [b]preventivo gratuito e senza impegno[/b]. Contattaci subito!
</p>
</div>
<div class="clearer"></div>
</div>
<p class="footer">
Made by [url="http://www.valeriacarpini.it"]valeria carpini[/url]
for Adesigns21</p>
</div>
<script type="text/javascript">
jQuery(document).ready(function($) {
// We only want these styles applied when javascript is enabled
$('div.navigation').css({'width' : '300px', 'float' : 'left'});
$('div.content').css('display', 'block');
// Initially set opacity on thumbs and add
// additional styling for hover effect on thumbs
var onMouseOutOpacity = 0.67;
$('#thumbs ul.thumbs li').opacityrollover({
mouseOutOpacity: onMouseOutOpacity,
mouseOverOpacity: 1.0,
fadeSpeed: 'fast',
exemptionSelector: '.selected'
});
// Initialize Advanced Galleriffic Gallery
var gallery = $('#thumbs').galleriffic({
delay: 2500,
numThumbs: 15,
preloadAhead: 10,
enableTopPager: true,
enableBottomPager: true,
maxPagesToShow: 7,
imageContainerSel: '#slideshow',
controlsContainerSel: '#controls',
captionContainerSel: '#caption',
loadingContainerSel: '#loading',
renderSSControls: true,
renderNavControls: true,
playLinkText: 'Play Slideshow',
pauseLinkText: 'Pause Slideshow',
prevLinkText: '‹ Previous Photo',
nextLinkText: 'Next Photo ›',
nextPageLinkText: 'Next ›',
prevPageLinkText: '‹ Prev',
enableHistory: false,
autoStart: false,
syncTransitions: true,
enableKeyboardNavigation: false,
defaultTransitionDuration: 900,
onSlideChange: function(prevIndex, nextIndex) {
// 'this' refers to the gallery, which is an extension of $('#thumbs')
this.find('ul.thumbs').children()
.eq(prevIndex).fadeTo('fast', onMouseOutOpacity).end()
.eq(nextIndex).fadeTo('fast', 1.0);
},
onPageTransitionOut: function(callback) {
this.fadeTo('fast', 0.0, callback);
},
onPageTransitionIn: function() {
this.fadeTo('fast', 1.0);
}
});
});
</script>
<script language="JavaScript">
// Code for validating the form
// Visit [url]http://www.javascript-coder.com/htm...alidation.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","Per favore inserisci il tuo nome");
frmvalidator.addValidation("lastname","req","Per favore inserisci il tuo cognome");
frmvalidator.addValidation("visitor_email","req","Per favore inserisci la tua email");
frmvalidator.addValidation("visitor_email","email","Per favore inserisci un indirizzo email valido");
frmvalidator.addValidation("address","req","Per favore inserisci il tuo indirizzo");
frmvalidator.addValidation("phone","req","Per favore inserisci il tuo telefono");
</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>
</body>
</html>