Learning PHP at the moment.
My form isn't working. I want a form that is extremely simple like this one and that works with reCAPTCHA.
1. The form needs to have a simple empty field check. As it is now, there are some form checks but obviously something isn't right because it goes through anyway. The messages you see should only be shown depending on what's going on.
2. I cannot make reCAPTCHA work.
Any help will be appreciated.
Code: Select all
<!-- PHP Code -->
<?php
$name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];
$from = 'From: mysite.com';
$to = 'sample@my.email.com';
$subject = 'you got an alien message from outer space';
$body = "From: $name\n E-Mail: $email\n Message:\n $message";
if ($_POST['submit']) {
if (mail ($to, $subject, $body, $from)) {
echo '<h5>Dude, your message has been sent!</h5>';
} else {
echo '<h5>Something went wrong, go back and try again!</h5>';
}
if ($email == "") {
echo "<h5>Hey, you must enter an e-mail address!</h5>";
}
}
?>
<!-- PHP Code -->
<div id="talk_form">
<form method="post" action="talk.php">
<fieldset>
<label>name</label>
<input name="name" type="text" placeholder="What's your name?">
<label>email</label>
<input name="email" type="email" placeholder="What's your email?">
<label>message</label>
<textarea name="message" placeholder="m., blah, blah, blah..."></textarea>
<script type="text/javascript"
src="http://www.google.com/recaptcha/api/challenge?k=my_key">
</script>
<noscript>
<iframe src="http://www.google.com/recaptcha/api/noscript?k=my_key"
height="300" width="500"></iframe><br>
<textarea name="recaptcha_challenge_field" rows="3" cols="40">
</textarea>
<input type="hidden" name="recaptcha_response_field"
value="manual_challenge">
</noscript>
<br />
<input id="submit" name="submit" type="submit" value="Send!">
</fieldset>
</form>
</div>