Jump to content

TorQueMoD

Members
  • Posts

    6
  • Joined

  • Last visited

TorQueMoD's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Ok so I fixed the problem. Thank you boompa for pointing out that gender was taking on the attributes of the phone number. I was able to fix the problem simply by specifying $string_exp = "/^[A-Za-z .'-]+$/"; for the gender and city. Thank you.
  2. Ok, apologies if I wasn't clear before. I know virtually nothing about php. This send form was created using a generator that for some reason didn't want to take credit for its work cause I've been trying for days to find it again so I can just re-make the form but sadly I can't. I have no idea what it means to put a condition after post mail nor how to do that and I also didn't realize that I was telling it to expect a 10 digit number after gender. Is there a way I can tell it to expect a drop down list for gender? I'm guessing what happened is because I told it to expect a 10 digit number for the phone and then didn't re-specify what to expect for city and gender its looking for the same there? I'll have to figure out what the code is to tell it to expect a drop down list. Thank you.
  3. Hey all, not sure this is considered a "math" problem, but I don't have a clue what regex is so I figured this is the best bet. I've been successfully using this code that was originally generated for me back in march (can't for the life of me figure out where it was generated) but recentely I wanted to add a new field to my form. I seem to have successfully added the new field (phone number) but in doing so, its broken the gender value. Here's the actual form: http://geekdomvancouver.com/register.html and here's the PHP for the send.php file <?php // CAPTCHA Code Start require_once('recaptchalib.php'); $privatekey = "6LcZZd4SAAAAAJ0QyQCCcfGpzOEjzZFybmIcvpB6"; $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 { // CAPTCHA Code Finish // Submit Code Start if(isset($_POST['email'])) { // EDIT THE 2 LINES BELOW AS REQUIRED $email_to = "info@torquemod.com"; $email_subject = "Geekdom Registration"; function died($error) { // your error code can go here echo "We are very sorry, but there were error(s) found with the form you submitted. "; echo "These errors appear below.<br /><br />"; echo $error."<br /><br />"; echo "Please go back and fix these errors.<br /><br />"; die(); } // validation expected data exists if(!isset($_POST['first_name']) || !isset($_POST['last_name']) || !isset($_POST['email']) || !isset($_POST['phone']) || !isset($_POST['city']) || !isset($_POST['gender'])) { died('We are sorry, but there appears to be a problem with the form you submitted.'); } $first_name = $_POST['first_name']; // required $last_name = $_POST['last_name']; // required $email_from = $_POST['email']; // required $phone = $_POST['phone']; // required $city = $_POST['city']; // required $gender = $_POST['gender']; // required $error_message = ""; $email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/'; if(!preg_match($email_exp,$email_from)) { $error_message .= 'The Email Address you entered does not appear to be valid.<br />'; } $string_exp = "/^[A-Za-z .'-]+$/"; if(!preg_match($string_exp,$first_name)) { $error_message .= 'The First Name you entered does not appear to be valid.<br />'; } if(!preg_match($string_exp,$last_name)) { $error_message .= 'The Last Name you entered does not appear to be valid.<br />'; } $string_exp = "/^[0-9]{3}[0-9]{3}[0-9]{4}$/i"; if(!preg_match($string_exp,$phone)) { $error_message .= 'The Phone Number you entered does not appear to be valid. Please enter only 10 numbers without - or spaces. Example: 7787787780 <br />'; } if(strlen($city) < 2) { $error_message .= 'The City you entered do not appear to be valid.<br />'; } if(!preg_match($string_exp,$gender)) { $error_message .= 'Please specify your gender<br />'; } if(strlen($error_message) > 0) { died($error_message); } $email_message = "Form details below.\n\n"; function clean_string($string) { $bad = array("content-type","bcc:","to:","cc:","href"); return str_replace($bad,"",$string); } $email_message .= "First Name: ".clean_string($first_name)."\n"; $email_message .= "Last Name: ".clean_string($last_name)."\n"; $email_message .= "Email: ".clean_string($email_from)."\n"; $email_message .= "Phone: ".clean_string($phone)."\n"; $email_message .= "City: ".clean_string($city)."\n"; $email_message .= "Gender: ".clean_string($gender)."\n"; // create email headers $headers = 'From: '.$email_from."\r\n". 'Reply-To: '.$email_from."\r\n" . 'X-Mailer: PHP/' . phpversion(); @mail($email_to, $email_subject, $email_message, $headers); ?> <!-- include your own success html here --> <!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>Geekdom Vancouver - All encompassing geek exposition</title> <META NAME="description" content="Geekdom Vancouver - All encompassing geek exposition held in Vancouver, British Columbia, Canada"> <META NAME="KEYWORDS" CONTENT="Geekdom, Vancouver, Expo, Fan Expo, Gaming Expo, Comic Con, Games, Cosplay, Geek, Nerd, Media, British Columbia, Canada, International"> <meta name="distribution" content="Global"> <META NAME="robots" content="index,follow"> <meta name="GOOGLEBOT" content="index,follow"> <META NAME="revisit-after" CONTENT="14 days"> </head> <style type="text/css"> body,td,th { font-family: "Comic Sans MS", cursive; font-size: 18px; color: #CCC; } body { background-color: #333; margin-left: 10px; margin-top: 0px; margin-right: 10px; margin-bottom: 0px; } a:link { color: #09F; } a:visited { color: #B340FF; } h1 { font-size: 36px; color: #44B144; } </style> <body> <div align="center"> <!--Start Logo--> <a href="http://www.geekdomvancouver.com/" target="_top"><img src="images/geekdom_logo_web.png" width="900" height="287" title="Geekdom Vancouver Home" alt="Geekdom Vancouver Home" /></a> <!--End Logo--> </div> <div align="left"> <p>Thank you for registering for Geekdom Vancouver: Year Zero. If you were among the first 100 users to register, you will be sent an e-mail shortly confirming your registration details and information on how to obtain your free day pass. If you were not among the first 100 registrants, thank you very much for taking the time to register. We will contact you with ticket purchasing information as soon as it becomes available. Thank you again for supporting Geekdom Vancouver.</p> </div> </body> </html> <?php } } ?> It doesn't matter what I do, the form always returns "We are very sorry, but there were error(s) found with the form you submitted. These errors appear below. Please specify your gender. Please go back and fix these errors." I tried changing the gender from a drop down list to 2 radio buttons but that simply returns the same error without specifying what the actual problem is. Anyone have any idea what I've done wrong? I'd rather not have to remove the gender field. Thanks!
  4. Ok, I was able to get everything working using a new code base that I found. For anyone else who might be interested in doing something similar, here is the code: HTML Form Code: <!-- Registration Start --> <form method="post" action="http://www.YOURDOMAIN.com/send.php"> <table width="50%" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="19%">First Name:</td> <td width="81%"><input type="text" name="first_name" id="first_name" /></td> </tr> <tr> <td> </td> <td> </td> </tr> <tr> <td>Last Name:</td> <td><input type="text" name="last_name" id="last_name" /></td> </tr> <tr> <td> </td> <td> </td> </tr> <tr> <td>Email:</td> <td><input type="text" name="email" id="email" /></td> </tr> <tr> <td> </td> <td> </td> </tr> <tr> <td>City:</td> <td><input type="text" name="city" id="city" /> *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></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=ENTER YOUR PUBLIC KEY HERE"> </script> <noscript> <iframe src="http://www.google.com/recaptcha/api/noscript?k=ENTER YOUR PUBLIC KEY HERE" 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 --> PHP Code for send.php: <?php // CAPTCHA Code Start require_once('recaptchalib.php'); $privatekey = "YOU PRIVATE CAPTCHA KEY HERE"; $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 { // CAPTCHA Code Finish // Submit Code Start if(isset($_POST['email'])) { // EDIT THE 2 LINES BELOW AS REQUIRED $email_to = "info@torquemod.com"; $email_subject = "Geekdom Registration"; function died($error) { // your error code can go here echo "We are very sorry, but there were error(s) found with the form you submitted. "; echo "These errors appear below.<br /><br />"; echo $error."<br /><br />"; echo "Please go back and fix these errors.<br /><br />"; die(); } // validation expected data exists if(!isset($_POST['first_name']) || !isset($_POST['last_name']) || !isset($_POST['email']) || !isset($_POST['city']) || !isset($_POST['gender'])) { died('We are sorry, but there appears to be a problem with the form you submitted.'); } $first_name = $_POST['first_name']; // required $last_name = $_POST['last_name']; // required $email_from = $_POST['email']; // required $city = $_POST['city']; // required $gender = $_POST['gender']; // required $error_message = ""; $email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/'; if(!preg_match($email_exp,$email_from)) { $error_message .= 'The Email Address you entered does not appear to be valid.<br />'; } $string_exp = "/^[A-Za-z .'-]+$/"; if(!preg_match($string_exp,$first_name)) { $error_message .= 'The First Name you entered does not appear to be valid.<br />'; } if(!preg_match($string_exp,$last_name)) { $error_message .= 'The Last Name you entered does not appear to be valid.<br />'; } if(strlen($city) < 2) { $error_message .= 'The City you entered do not appear to be valid.<br />'; } if(!preg_match($string_exp,$gender)) { $error_message .= 'Please specify your gender<br />'; } if(strlen($error_message) > 0) { died($error_message); } $email_message = "Form details below.\n\n"; function clean_string($string) { $bad = array("content-type","bcc:","to:","cc:","href"); return str_replace($bad,"",$string); } $email_message .= "First Name: ".clean_string($first_name)."\n"; $email_message .= "Last Name: ".clean_string($last_name)."\n"; $email_message .= "Email: ".clean_string($email_from)."\n"; $email_message .= "City: ".clean_string($city)."\n"; $email_message .= "Gender: ".clean_string($gender)."\n"; // create email headers $headers = 'From: '.$email_from."\r\n". 'Reply-To: '.$email_from."\r\n" . 'X-Mailer: PHP/' . phpversion(); @mail($email_to, $email_subject, $email_message, $headers); ?> <!-- include your own success html here --> <!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> </head> <body> This is the HTML code for your success/thank you page. </body> </html> <?php } } ?>
  5. yes I realized the thankyou message was outside of the if statement. I figured that's where I'd put the thankyou page html info. What I was hoping to do is simply have a pop up message of some kind that would stop the form from submitting if the required fields are missing. As for the mail function, I didn't realize I needed to add one but of course that's obvious now that you mention it So right now all the form is doing is submitting to the send.php file but the send,php file needs to specify where to send the gathered information. I'll look into how to add that to the page. Thank you.
  6. 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!
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.