Вы находитесь на странице: 1из 4

Tutorial

THE VIEWFINDER FEEDBACK FORM


----------------------------------------------------------Written by Lee Penney
Visit Viewfinder Design at www.viewfinderdesign.co.uk
or, check out Lee's blog at www.thedigeratipeninsula.org.uk
-----------------------------------------------------------

This is a simple to use and install feedback form that requires PHP to work.
To use, edit the mail.php file and replace the email address, return page (this can remain at the default unless you have a r eason
for changing it) and the site name with your details.
Edit the contact.html and thankyou.html files so they match the look of your site.
Upload all of these files to your server (in the same directory), and test.
Voila, you're done, easy as that.
If you have any problems, check out the Viewfinder Design support forums at www.viewfinderdesign.co.uk/support/

Mail.php
<?
/* Edit these preferences to suit your needs */
$mailto = 'your@email-address.com'; // insert the email address you want the form sent to
$returnpage = 'thankyou.html'; // insert the name of the page/location you want the user to be returned to
$sitename = '[You Site Name]'; // insert the site name here, it will appear in the subject of your email
/* Do not edit below this line unless you know what you're doing */
$name = $_POST['name'];
$email = $_POST['email'] ;
$enquiry = stripslashes($_POST['query']);
if (!$name) {
print("<strong>Error:</strong> Please provide your name.<br/><br/><a href='javascript:history.go( 1)'>Back</a>");
exit;
}
if (!$email) {
print("<strong>Error:</strong> Please provide an email address.<br/><br/><a href='javascript:history.go( 1)'>Back</a>");
exit;
}
if (!$enquiry) {
print("<strong>Error:</strong> Please provide your enquiry details.<br/><br/><a href='javascript:history.go(1)'>Back</a>");
exit;
}
if (!eregi("^[a-z0-9]+([-_\.]?[a-z0-9])+@[a-z0-9]+([-_\.]?[a-z0-9])+\.[a-z]{2,4}", $email)){
print("<strong>Error:</strong> this email address is not in a valid format.<br/><br/><a href='javascript:history.go( 1)'>Back</a>");
exit;
}
$message = "\n$name submitted the following message:\n\n$enquiry\n\nTheir contact details are as follows:\n\nName:
$name\nEmail Address: $email\n\n";
mail($mailto, "$sitename Contact Form Enquiry from $name", $message, "From: $email");
header("Location: " . $returnpage);
?>

Contact.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1 -transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Contact Form</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<!-- <link href="default.css" rel="stylesheet" type="text/css" /> -->
</head>
<body>
<p>This is a standard contact form that will work with the mail file in this package.
paste the following code and style as appropriate.</p>
<form action="mail.php" method="post">
<label>Name:</label><input type="text" name="name" /><br/>
<label>Email Address:</label><input type="text" name="email" /><br/>
<label>Message:</label><textarea name="query"></textarea><br/>
<input type="submit" name="submit" value="Send" />
</form>
</body>
</html>

Simply copy and

Thankyou.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1 -transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Contact Form</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<!-- <link href="default.css" rel="stylesheet" type="text/css" /> -->
</head>
<body>
<p>Thank you for contacting up, we will get back to you as soon as possible. </p>
</body>
</html>

Вам также может понравиться