jeffpoulsen Posted September 28, 2007 Share Posted September 28, 2007 I have a form that when properly filled out I would like to send the visitor to a new page. Not an include but a new page that thanks them for filling out the form and then redirects them to the site. I have found that goto is not included in PHP. Most examples I have found have many lines of code and seem so complicated. Is there a way to have this done simply? All help is greatly appreciated. Quote Link to comment https://forums.phpfreaks.com/topic/70975-send-users-to-thankyou-page/ Share on other sites More sharing options...
freakstyle Posted September 28, 2007 Share Posted September 28, 2007 what your looking for can be found here: http://us.php.net/header good luck Quote Link to comment https://forums.phpfreaks.com/topic/70975-send-users-to-thankyou-page/#findComment-356875 Share on other sites More sharing options...
chronister Posted September 28, 2007 Share Posted September 28, 2007 Well first you have to have "all that code" to validate that the form is filled out properly... once you have validated it and confirmed that its correct you would then use the header() function as freakstyle said. I have found that almost nothing is "simple - 1 or 2 lines" in php. If you want to make sure that a form is correct, you have to have quite a bit of code to make it happen. I am working on a form right now that has over 30 fields with some being required dependent on the value selected for another field. I am not even done with it yet and it has almost 200 lines of code in it. Any script done correctly will generally be fairly lengthy. I suggest you use this opportunity to learn that "complicated" coding as it is probably not as complicated as it seems. Quote Link to comment https://forums.phpfreaks.com/topic/70975-send-users-to-thankyou-page/#findComment-357002 Share on other sites More sharing options...
jeffpoulsen Posted September 28, 2007 Author Share Posted September 28, 2007 Thanks freakstyle and chronister, My problem is I'm not to familiar with php. If I am reading correctly I need to end the session and destroy the existing header??? This comes at a place in the code when all conditions have been met. It's part of a "if" "else" statement. I don't know how to break out of the php page and return to the html site. Quote Link to comment https://forums.phpfreaks.com/topic/70975-send-users-to-thankyou-page/#findComment-357199 Share on other sites More sharing options...
chronister Posted September 28, 2007 Share Posted September 28, 2007 <?php if($all_fields_validated=='Yes') { header('Location:http://yoursite.com/thankyoupage.php') } else { echo 'Please fix the errors before proceeding'; } ?> You don't need to destroy the session and header, you just need to call the header() at the right time. See example above... It's a very simplistic example. Nate Quote Link to comment https://forums.phpfreaks.com/topic/70975-send-users-to-thankyou-page/#findComment-357325 Share on other sites More sharing options...
jeffpoulsen Posted September 29, 2007 Author Share Posted September 29, 2007 Thanks Chronister Below is the end of the code. Some parts are commented out for testing. I still recieve an error about sending the headers: if($valid == true) { //Sending Email to form owner /* $pfw_header = "From: $email\n" . "Reply-To: $email\n"; $pfw_subject = "From Join ML Form"; $pfw_email_to = "nobody@nowhere.non"; $pfw_message = "Visitor's IP: $pfw_ip\n" . "name: $name\n" . "lastname: $lastname\n" . "company: $company\n" . "title: $title\n" . "address1: $address1\n" . "address2: $address2\n" . "city: $city\n" . "state: $state\n" . "zip: $zip\n" . "email: $email\n" . "interests: $interests\n" . "other_interest: $other_interests\n" . "End of information"; @mail($pfw_email_to, $pfw_subject ,$pfw_message ,$pfw_header ); */ header("Location: http://ourloca.tion/form_completed.php"); } else { echo "<center><a href=\"javascript:history.go(-1)\">Sorry, the code you entered was invalid<br>Go back to form</center>"; } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/70975-send-users-to-thankyou-page/#findComment-357809 Share on other sites More sharing options...
Cagecrawler Posted September 29, 2007 Share Posted September 29, 2007 When sending a header, nothing can have been sent to the browser already. Make sure no html or whitespace has been sent - if it has then you'll need to use output buffering. http://uk2.php.net/manual/en/function.ob-start.php Quote Link to comment https://forums.phpfreaks.com/topic/70975-send-users-to-thankyou-page/#findComment-357815 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.