Hey all,
So I've been at this all day yesterday and most of today and I'm about ready to smash my head through my monitor. I'm not a programmer by any means, but this code is simple enough that it should be working. Unfortunately it does not and I'm not knowledgeable enough to figure out why.
I've got a form on my website that I want to use to collect information from people who decide to fill it out. The form can be seen at http://www.geekdomvancouver.com/register.html
Here's the HTML code for the form:
<!-- Registration Start --> <form onsubmit="return alertemail(r_email)" method="post" action="http://www.geekdomvancouver.com/send.php" name="registration_form" id="reg_form" $from_address = "info@geekdomvancouver.com";> <input type='hidden' name='rec_mailto' value='info@torquemod.com' /> <input type='hidden' name='rec_subject' value='Geekdom Registration' /> <input type='hidden' name='rec_thanks' value='thanks.html' /> <table width="50%" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="19%">Full Name:</td> <td width="81%"><input type="text" name="name" id="name" /> (First and Last name)</td> </tr> <tr> <td> </td> <td> </td> </tr> <tr> <td>Email:</td> <td><input type="text" name="email" id="email" /> (Your email address)</td> </tr> <tr> <td> </td> <td> </td> </tr> <tr> <td>City:</td> <td><input type="text" name="city" id="city" /> (What city do you live in?) *only GVRD residents can win</td> </tr> <tr> <td> </td> <td> </td> </tr> <tr> <td>Gender:</td> <td><select name="gender" id="gender"> <option>Male</option> <option>Female</option> <option selected="selected"></option> </select> (Are you male or female?)</td> </tr> <tr> <td> </td> <td> </td> </tr> <tr> <td> </td> <td><!-- Recaptcha Start --> <script type="text/javascript" src="http://www.google.com/recaptcha/api/challenge?k=6LcZZd4SAAAAAJe-twy5RJyWbFYluHWLPuvQkQuB"> </script> <noscript> <iframe src="http://www.google.com/recaptcha/api/noscript?k=6LcZZd4SAAAAAJe-twy5RJyWbFYluHWLPuvQkQuB" height="300" width="500" frameborder="0"></iframe><br> <textarea name="recaptcha_challenge_field" rows="3" cols="40"> </textarea> <input type="hidden" name="recaptcha_response_field" value="manual_challenge"> </noscript> <!-- Recaptcha End --></td> </tr> <tr> <td> </td> <td> </td> </tr> <tr> <td><input type="reset" name="Reset" id="Reset" value="Reset" /></td> <td><input type="submit" name="Submit" id="Submit" value="I agree with the above stated rules. Please Submit my information" /></td> </tr> </table> </form> <!-- Registration End -->
and the code for my send.php file:
<?php require_once('recaptchalib.php'); $privatekey = "private key is in here but I'm not going to show it"; $resp = recaptcha_check_answer ($privatekey, $_SERVER["REMOTE_ADDR"], $_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"]); if (!$resp->is_valid) { // What happens when the CAPTCHA was entered incorrectly die ("The reCAPTCHA wasn't entered correctly. Go back and try it again." . "(reCAPTCHA said: " . $resp->error . ")"); } else { // define variables and initialize with empty values $nameErr = $emailErr = $cityErr = $genderErr = ""; $name = $email = $city = $gender = array(); if ($_SERVER["REQUEST_METHOD"] == "POST") { if (empty($_POST["name"])) { $nameErr = "Missing"; } else { $name = $_POST["name"]; } if (empty($_POST["email"])) { $emailErr = "Missing"; } else { $email = $_POST["email"]; } if (empty($_POST["city"])) { $cityErr = "Missing"; } else { $city = $_POST["city"]; } if (empty($_POST["gender"])) { $genderErr = "You must specify your gender"; } else { $gender = $_POST["gender"]; } } } ?> Thank you for submitting your application.
Now my problem is twofold. Firstly, if I leave all of the form fields blank, it still proceeds to submit the form so validation is not working. Secondly, if I enter all of the information correctly, and press submit nothing happens. It parses the send.php file and displays the thank you message but no e-mail is sent.
Is this because the send.php doesn't contain the form itself? Is there some way I'm supposed to pass the form info on to the send.php that I'm not doing? I thought that's what I was doing when defining the variables.
Thanks!