Lyfa The Lonely Man Reputation: 12
Joined: 02 Nov 2008 Posts: 744
|
Posted: Sat Apr 24, 2010 1:08 pm Post subject: My new contact form |
|
|
Any suggestions? - http://quinnheagy.org/contact.php
Code is:
Code: | <head>
<title>Contact Quinn Heagy: Contact Form</title>
<link type="text/css" rel="stylesheet" href="css/main.css" />
</head>
<body>
<?php
if (isset($_POST['submit'])){
if(empty($_POST['email'])){
echo "Please enter an email";
} elseif (empty($_POST['subject'])){
echo "Please enter a subject";
} elseif (empty($_POST['message'])){
echo "Please enter a message";
} elseif ($_POST['message'] == "Enter your message here..") {
echo "Please enter an original message";
} else {
require_once('recaptchalib.php');
$privatekey = "...";
$resp = recaptcha_check_answer ($privatekey,
$_SERVER["REMOTE_ADDR"],
$_POST["recaptcha_challenge_field"],
$_POST["recaptcha_response_field"]);
if (!$resp->is_valid) {
die ("The reCAPTCHA wasn't entered correctly. Go back and try it again." .
"(reCAPTCHA said: " . $resp->error . ")");
}
$message = "From: $_POST[email]\nIP: $_SERVER[REMOTE_ADDR]\nMessage: ";
$subject = "QuinnHeagy.org Contact Form: ";
$subject .= trim(strip_tags($_POST['subject']));
$message .= trim(strip_tags($_POST['message']));
if (mail("[email protected]" , $subject , $message , "[email protected]")) {
echo '<script>document.location.href = "sent.php";</script>';
} else {
echo "There was an error. Your message was not sent. <a href='/contact.php'>Go back</a> and resend it";
}
}
} else {
?>
<form method="POST" action="contact.php">
Email: <input type="text" name="email" />
Subject: <input type="text" name="subject" /><br />
<textarea rows="4" cols="50" name="message" >Enter your message here..</textarea><br />
<center><?php
require_once('recaptchalib.php');
$publickey = "..."; // you got this from the signup page
echo recaptcha_get_html($publickey);
?></center>
<input type="submit" value="Send message" /> • <input type="reset" value="Reset" /><br />
<input type="hidden" name="submit" value="true" />
</form>
<?php
}
?>
</body> |
_________________
|
|