mrjap1 Posted May 14, 2011 Share Posted May 14, 2011 Hello All, I made an external "Thank you.html" page that I want to show immediately after the " Send Your Info" button on my "request_more_info.php " form is clicked. This MUST stay external always. I want this to be called in somehow by php. So is there some php code I can use to accomplish this? Also is there some php code I can use to validate my entire form and ESPECIALLY the e-mail address portion on my form? If so could you tell me who do i apply it to my "request_more_info.php " Salutation: (radio buttons) First Name: (input field) Last Name: (input field) Address: (input field) City: (input field) State: (select option) Zip: (input field) Country: (select option) Email: (input field) Our Newsletter: (radio buttons) Thx MrJAP1 Quote Link to comment https://forums.phpfreaks.com/topic/236422-contact-form-help-with-php-051411/ Share on other sites More sharing options...
HDFilmMaker2112 Posted May 14, 2011 Share Posted May 14, 2011 Here's the way I do validation: When the user submits the form it is submitted to a new page, on that page: $name=$_POST['name']; if($name==""){ $error0=1; } else{ $error0=0; } Do the above for each item you want to validate. Incrementing the number after error in the $error variable. i.e; $error0,$ error1, $error2, ect. Once you review each form item forward the user back to the form or to your thank you page, via a header redirect. if($error!=="0000000"){ header("Location: ./request_more_info.php?error=".$error0."".$error1."".$error2."".$error3."".$error4."".$error5."".$error6.""); } else{ header("Location: URL for thank you page"); To alter the above you would have to take the total amount of form items you are validating, and place that amount of "0" in this: if($error!=="0000000"){ And then on your initial submitting form: $error=$_GET['error']; <p><label>Name:</label> <input type="text" name="name" size="30" />'; if($error[0]==1){ $content.=' <span class="red bold">This field is required.</span>'; } $content.='</p> So your flow is essentially: submitting form ----> process/validate form if errors, redirect back to submitting form with error=error code in URL else, no errors, forward to thank you page You'll need to alter this above code to suit your needs better, especially the CSS class calls and what not. Quote Link to comment https://forums.phpfreaks.com/topic/236422-contact-form-help-with-php-051411/#findComment-1215504 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.