mat420 Posted February 18, 2011 Share Posted February 18, 2011 thanks x a million in advance people. ok i know no php but i feel like im really close to editing this code to how i want it. i want one send to check the text box captcha and everything else listed there and i want send2 to check if email1 and email2 match, and if they do, then mail email1 and/or 2. i preferably need to also have a separate one of these for send2 also: <?php if (isset($errors)) { foreach ($errors as $error) { echo("<p>$error<p>\n"); } } ?> heres what i have otherwise, i basically just copied two php "if ___, then do ___" above eachother. <?php if ($_POST['send']) { $errors = array(); if ($_POST['captcha'] != $_SESSION['captchacode']) { $errors[] = "You didn't enter the correct letters!"; } if (empty($_POST['email'])) { $errors[] = "Please enter an e-mail address"; } else if (!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $_POST['email'])) { $errors[] = 'Please enter a valid e-mail address'; } if ($_POST['email1'] != $_POST['email2']) { $errors[] = "The two emails do not match!"; } if (!count($errors)) { // IMPORTANT: If you don't call this the // user will keep getting the SAME code! captchaDone(); $name_field = $_POST['name']; $email_field = $_POST['email']; $message = $_POST['message']; $phone = $_POST['phone']; $optional = $_POST['callback']; $cs = $_POST['cs']; $email1 = $_POST['email1']; $email2 = $_POST['email2']; $body = "Name: $name_field, Email: $email_field, Phone: $phone, Location: $cs, Call Them! $optional, Message: $message"; mail($myaddress, 'Contact Form Submission', $body); // Notice we can shift in and out of "HTML mode" // to display some HTML only when the // user passes the test ?> <?php if ($_POST['send2']) { $errors = array(); if ($_POST['captcha2'] != $_SESSION['captchacode']) { $errors[] = "You didn't enter the correct letters!"; } if (empty($_POST['email1'])) { $errors[] = "Please enter an e-mail address"; } else if (!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $_POST['email1'])) { $errors[] = 'Please enter a valid e-mail address'; } if ($_POST['email1'] != $_POST['email2']) { $errors[] = "The two emails do not match!"; } if (!count($errors)) { // IMPORTANT: If you don't call this the // user will keep getting the SAME code! captchaDone(); $email1 = $_POST['email1']; $email2 = $_POST['email2']; $body = "$email1, $email2"; mail($myaddress, 'Contact Form Submission', $body); // Notice we can shift in and out of "HTML mode" // to display some HTML only when the // user passes the test ?> Quote Link to comment Share on other sites More sharing options...
mat420 Posted February 18, 2011 Author Share Posted February 18, 2011 bumpsssss Quote Link to comment Share on other sites More sharing options...
denno020 Posted February 18, 2011 Share Posted February 18, 2011 Do you know that you have a few missing closing curly brackets? I'm trying to find where if statements start and end, but I'm finding it very hard... Also, what is the purpose of send1 and send2? Are these options in the form? Denno Quote Link to comment Share on other sites More sharing options...
mat420 Posted February 18, 2011 Author Share Posted February 18, 2011 else if (!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $_POST['email1'])) should there be one between those 2 lines? well send1 and send2 both are suppose to check captchas and meet other criteria before submitting. i dont really care if the same captcha shows, so i used the same image (if thats even possible..with two different criterias needing to be met) but i want send1, to check email entered, valid email, valid captcha on the right hand side and then send2 on the left, i want to check email1 and email2 text boxes to make sure they match, as well as captcha and send if so. http://aciddr0p.net/drtest/demo2.php <- ignore the "email us" button, and theres an emample. i need a new error label for the left hand side too. im trying to create a quick ...wow im an idiot. im making a "request a call back" not request an email back. email1 and email2 need to have matching PHONE NUMBERS not emails. not that it makes a difference. thank you. Quote Link to comment Share on other sites More sharing options...
denno020 Posted February 18, 2011 Share Posted February 18, 2011 Ahhh now this makes sense lol. What I would do is pretty similar to what you have.. Give each submit button a different name, then when processing in php: //assuming left send button is called submitEmail and right is called submitContact if(isset($_POST["submitEmail"])){ //do the form processing for the email submission part }else if(isset($_POST["submitContact"])){ //do the form processing for the contact part } Is that the sort of thing you're after? Denno Quote Link to comment Share on other sites More sharing options...
mat420 Posted February 18, 2011 Author Share Posted February 18, 2011 well look, this is the working code, to check the form on the right. and send if everythings good. <?php if ($_POST['send']) { $errors = array(); if ($_POST['captcha'] != $_SESSION['captchacode']) { $errors[] = "You didn't enter the correct letters!"; } if (empty($_POST['email'])) { $errors[] = "Please enter an e-mail address"; } else if (!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $_POST['email'])) { $errors[] = 'Please enter a valid e-mail address'; } if ($_POST['email1'] != $_POST['email2']) { $errors[] = "The two emails do not match!"; } if (!count($errors)) { // IMPORTANT: If you don't call this the // user will keep getting the SAME code! captchaDone(); $name_field = $_POST['name']; $email_field = $_POST['email']; $message = $_POST['message']; $phone = $_POST['phone']; $optional = $_POST['callback']; $cs = $_POST['cs']; $email1 = $_POST['email1']; $email2 = $_POST['email2']; $body = "Name: $name_field, Email: $email_field, Phone: $phone, Location: $cs, Call Them! $optional, Message: $message"; mail($myaddress, 'Contact Form Submission', $body); // Notice we can shift in and out of "HTML mode" // to display some HTML only when the // user passes the test ?> i need to know how to add if commands for ANOTHER button now, it didnt let me just put it right underneith (send2). Quote Link to comment Share on other sites More sharing options...
denno020 Posted February 18, 2011 Share Posted February 18, 2011 What didn't let you? I don't understand the problem you're having? Quote Link to comment Share on other sites More sharing options...
mat420 Posted February 18, 2011 Author Share Posted February 18, 2011 my code looks good then? all i did was take the code i showed u right in the last post and i added this immediately underneath it: <?php if ($_POST['send2']) { $errors = array(); if ($_POST['captcha2'] != $_SESSION['captchacode']) { $errors[] = "You didn't enter the correct letters!"; } if (empty($_POST['email1'])) { $errors[] = "Please enter an e-mail address"; } else if (!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $_POST['email1'])) { $errors[] = 'Please enter a valid e-mail address'; } if ($_POST['email1'] != $_POST['email2']) { $errors[] = "The two emails do not match!"; } if (!count($errors)) { // IMPORTANT: If you don't call this the // user will keep getting the SAME code! captchaDone(); $email1 = $_POST['email1']; $email2 = $_POST['email2']; $body = "$email1, $email2"; mail($myaddress, 'Contact Form Submission', $body); // Notice we can shift in and out of "HTML mode" // to display some HTML only when the // user passes the test ?> Quote Link to comment Share on other sites More sharing options...
denno020 Posted February 18, 2011 Share Posted February 18, 2011 It needs to be an else if mate. The user can't hit both the submit buttons at the same time? So you're checking one OR the other, not both... Also, on your site, you don't have any form tags for the email part, only in the contact part.. I assume you will be fixing this up? Denno Quote Link to comment Share on other sites More sharing options...
mat420 Posted February 18, 2011 Author Share Posted February 18, 2011 i dont follow. what exactly is wrong? what needs to be self if exactly? when i had the 2nd to last code posted, it worked fine on that contact form. i made "name" and "email" have to match before it sent (just as a test), but when i tried to make that a requirement on the left hand side, on 2 new text boxes, it didnt work. then if it helps any i got this thats USING that php - sorruy for the mess <input type="text" name="email1" id="email1" MAXLENGTH=30 value="<?php if (!empty($_POST['email1'])) { echo $_POST['email1']; } ?>" /> <input type="text" name="email2" id="email2" MAXLENGTH=30 value="<?php if (!empty($_POST['email2'])) { echo $_POST['email2']; } ?>" /> </p> <td valign="top"><input name="captcha2" size="8"/> </td> </tr><tr> <td valign="top"><span class="class2"> <label for="Message"><a href="<?php echo captchaWavUrl()?>">Listen To This</a> / <a href="javascript:location.reload(true);">Refresh</a></label></span> </td> </tr> <tr> <img style="vertical-align: middle" src="<?php echo captchaImgUrl()?>"> <input type="submit" name="send2" value="Submit"/> <font color="red"><b><?php if (isset($errors)) { foreach ($errors as $error) { echo("<p>$error<p>\n"); } } ?> Quote Link to comment Share on other sites More sharing options...
mat420 Posted February 18, 2011 Author Share Posted February 18, 2011 i dont follow. if send1 is hit it checks one thing (actually 2-3) and if send2 is hit, it checks email1 and email2 i can make it do that i think. i just needd to know hoq to setup the 2 different scenarios if i cant just put them right above/under eachother Quote Link to comment Share on other sites More sharing options...
denno020 Posted February 18, 2011 Share Posted February 18, 2011 Yeah man that's what I'm trying to tell you... From the code that I posted, only one if section will run, so it doesn't matter if you have similar or the same code in the top 'if' as you do in the 'else if' because only one will run. Follow the format that I gave you, and you shouldn't have any problems.. Denno Quote Link to comment Share on other sites More sharing options...
mat420 Posted February 18, 2011 Author Share Posted February 18, 2011 what format did u give me? im lost. gonna go waste another 5 hours figuring this out. be back im sure. Quote Link to comment Share on other sites More sharing options...
denno020 Posted February 18, 2011 Share Posted February 18, 2011 Dude seriously... Here is the code again, read the comments in the code (they'll appear orange) //assuming left send button is called submitEmail and right is called submitContact if(isset($_POST["submitEmail"])){ //do the form processing for the email submission part }else if(isset($_POST["submitContact"])){ //do the form processing for the contact part } I can't help you any further if you can't understand what I'm suggesting to you here.. Denno Quote Link to comment Share on other sites More sharing options...
mat420 Posted February 18, 2011 Author Share Posted February 18, 2011 i just wanna make sure were on the same page at least, u see that this part is my error right? as soon as i put this "if send button is hit" under the under "if send button is hit" the page stops loading Parse error: syntax error, unexpected $end in /homepages/4/d289686807/htdocs/drtest/demo2.php on line 735 thanks man Quote Link to comment Share on other sites More sharing options...
mat420 Posted February 18, 2011 Author Share Posted February 18, 2011 PROBLEM SOLVED. ONE MORE ISSUE AND I THINK IM DONE WITH THIS STUPID SITE LOL thanks all! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.