קוד:
<!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>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
</head>
<body>
<?
// keep people from accessing this page directly
if (eregi('contact.php', $_SERVER['PHP_SELF'])) {
// go to index page
header('Location: ../main.php?page=contact');
die();
}
?>
<h4>Contact Form</h4>
<?php
echo "<p>* Denotes required fields. </p>";
// put your email here
$send_to = "youremail@your.com";
// This is what is displayed in the email subject line
$subject = "Message from Your Website";
// This is displayed if all the fields are not filled in
$empty_fields_message = "<p>Please <a href='contact.php'>go back</a> and complete all the fields in the form!</p>";
// This is displayed when the email has been sent
$thankyou_message = "<p>Thankyou. Your message has been sent! =)<br /><br /><a href='index.php'><< Back to Main</a></p>";
// set up info
$nowDay=date("m.d.Y");
$nowClock=date("H:i:s");
$http_referrer = getenv( "HTTP_REFERER" );
// You do not need to edit below this line
$name = stripslashes($_POST['txtName']);
$email = stripslashes($_POST['txtEmail']);
$phone = stripslashes($_POST['txtPhone']);
$message = stripslashes($_POST['txtMessage']);
if (!isset($_POST['txtName'])) {
?>
</p>
<form method="post" action="<?php echo $_SERVER['REQUEST_URI']; ?>" id="mailme" name="mailme">
Name: <span class="error"> *</span><br />
<input name="txtName" type="text" title="Enter your name" size="35" maxlength="20"/>
<p> Email: <span class="error"> *</span><br />
<input name="txtEmail" type="text" title="Enter your email address" size="35" maxlength="30"/>
</p>
<p> Phone:<br />
<input name="txtPhone" type="text" title="Enter your phone number" size="35" maxlength="20"/>
</p>
<p>Contact? </p>
<input name="contact" type="radio" value="yes" checked>
Yes<br />
<input name="contact" type="radio" value="no">
No
<p>How did you find us?</p>
<input name="found" type="radio" value="advertisement">Advertisement <br />
<input name="found" type="radio" value="wordofmouth">Word of Mouth <br />
<input name="found" type="radio" value="search_engine">Search Engine <br />
<input name="found" type="radio" value="web_link">Web Link <br />
<input name="found" type="radio" value="other" checked>Other<br />
<p> Message: <span class="error"> *</span> <br />
<textarea name="txtMessage" cols="50" rows="10" wrap="VIRTUAL" /></textarea></p>
<p>
<input name="Reset" type="reset" value="Clear"/>
<input name="submit" type="submit" value="Send"/>
</p>
</form>
<?php
}
elseif (empty($name) || empty($email) || empty($message)) {
echo @$empty_fields_message;
}
else {
// Stop the form being used from an external URL
// Get the referring URL
@$referer = $_SERVER['HTTP_REFERER'];
// Get the URL of this page
@$this_url = "http://".$_SERVER['HTTP_HOST'].$_SERVER["REQUEST_URI"];
// If the referring URL and the URL of this page don't match then
// display a message and don't send the email.
if ($referer != $this_url) {
echo "You do not have permission to use this script from another URL.";
exit;
}
@$messageproper =
// we now generate a nice form for emailing
"Message recieved: $nowDay at $nowClock:\n\n" .
"Email Sent From: $http_referrer\n\n" .
"Name: $name\n\n".
"Email: $email\n\n".
"Phone Number: $phone\n\n".
"Contact?: $contact\n\n".
"Found site By: $found\n\n".
"------------------------ COMMENTS ------------------------\n\n\n" .
$message .
"\n\n\n----------------------------------------------------------\n" ;
// The URLs matched so send the email
mail($send_to, $subject, $messageproper, "From: $name <$email>");
# Autoresponder #############################################################
// note , the . (dot) joins two strings. to end a string, use semi-colon ;
$replysubject =
"Query from Your Website" ; // send our subject header
$replymessage =
"Dear " .
$name .
"\n\nThank you for your email. \nIf you had so requested, we will get back to you as soon as possible. " .
"\n\nRegards," .
"\n Your Name Here" .
mail( "$email", "$replysubject", "$replymessage\n\n", "From:$send_to" );
// Display the thankyou message
echo $thankyou_message;
}
?>
</body>
</html>
ראיתי באיזה אתר אחד קחו