humair77 Posted February 13, 2008 Share Posted February 13, 2008 I need to redirect to a static thankyou page after a user submit the form. I used header("Location: thankyou.html"); to redirect the page but it is NOT working ... Please let me know what is the best way to redirect this different page after form submission. <?php error_reporting(E_PARSE); define("ADMIN_MAIL", "jb@bwp.net"); define("HOST_NAME", $_SERVER['HTTP_HOST']); define("PHP_SELF", $_SERVER['PHP_SELF']); define('FORM_RECIPIENT', 'webmaster@lenapebuilder.net'); $isHideForm = false; if( $HTTP_POST_VARS["formmail_submit"] ){ header("Location: thankyou.html"); exit(); } ?> <?php $ip = $_POST['ip']; $httpref = $_POST['httpref']; $httpagent = $_POST['httpagent']; $customer_name = $_POST['customer_name']; $customer_email = $_POST['customer_email']; $customer_address = $_POST['customer_address']; $customer_city = $_POST['customer_city']; $customer_state = $_POST['customer_state']; $customer_zip = $_POST['customer_zip']; $customer_phone = $_POST['customer_phone']; $customer_email = $_POST['customer_email']; $subject = CustomerContact_Form; $message = " $todayis [EST] \n Name: $customer_name \n Address: $customer_address \n City: $customer_city \n State: $customer_state \n Zip: $customer_zip \n Phone: $customer_phone \n "; $from = "From: $customer_email\r\n"; mail("webmaster@lenape.net", $subject, $message, $from ); ?> Quote Link to comment https://forums.phpfreaks.com/topic/90809-redirect-to-thankyou-page/ Share on other sites More sharing options...
wintallo Posted February 13, 2008 Share Posted February 13, 2008 How is it not working? Is it throwing an error? Also, make sure no html is before the header("Location... part. This includes echoing or printing any text. -wintallo Quote Link to comment https://forums.phpfreaks.com/topic/90809-redirect-to-thankyou-page/#findComment-465450 Share on other sites More sharing options...
haku Posted February 13, 2008 Share Posted February 13, 2008 And which version of php are you using? Quote Link to comment https://forums.phpfreaks.com/topic/90809-redirect-to-thankyou-page/#findComment-465575 Share on other sites More sharing options...
Isityou Posted February 13, 2008 Share Posted February 13, 2008 This works to, but uses javascript. <?php if( $HTTP_POST_VARS["formmail_submit"] ) { echo '<script>parent.location = 'thankyou.html';</script>'; } ?> Bizarre but works Quote Link to comment https://forums.phpfreaks.com/topic/90809-redirect-to-thankyou-page/#findComment-465615 Share on other sites More sharing options...
digitalmartyr Posted February 13, 2008 Share Posted February 13, 2008 try putting the if statement where the header is in the first few lines of the code. are you getting a header alerady sent error? sometimes header doesnt work like it should if there are other things before it. Chad Quote Link to comment https://forums.phpfreaks.com/topic/90809-redirect-to-thankyou-page/#findComment-465617 Share on other sites More sharing options...
haku Posted February 13, 2008 Share Posted February 13, 2008 This works to, but uses javascript. Only works if they have javascript turned on. Quote Link to comment https://forums.phpfreaks.com/topic/90809-redirect-to-thankyou-page/#findComment-465642 Share on other sites More sharing options...
Isityou Posted February 13, 2008 Share Posted February 13, 2008 Most people have javascript enabled. Does this work? if( isset($HTTP_POST_VARS["formmail_submit"]) ){ header("Location: thankyou.html"); exit(); } Quote Link to comment https://forums.phpfreaks.com/topic/90809-redirect-to-thankyou-page/#findComment-466039 Share on other sites More sharing options...
revraz Posted February 13, 2008 Share Posted February 13, 2008 This makes no sense to me. Since there is no FORM on that page, is this being called from another page? If so, and the header does work, that means all the code below it won't even get called. May also want to use $_POST as well. Quote Link to comment https://forums.phpfreaks.com/topic/90809-redirect-to-thankyou-page/#findComment-466040 Share on other sites More sharing options...
haku Posted February 13, 2008 Share Posted February 13, 2008 Most people have javascript enabled. Most isn't all. If you are doing an amateur site it doesn't matter, but if you are programming real, professional sites, that fact cannot be overlooked. Quote Link to comment https://forums.phpfreaks.com/topic/90809-redirect-to-thankyou-page/#findComment-466042 Share on other sites More sharing options...
phpSensei Posted February 13, 2008 Share Posted February 13, 2008 Most people have javascript enabled. Most isn't all. If you are doing an amateur site it doesn't matter, but if you are programming real, professional sites, that fact cannot be overlooked. Most is the majority, your chances of someone being the minority of that group would be low. Go with HEADER("Location:index.php") or something... Or you can use a cheap meta refresh method <meta http-equiv="refresh" content="15;url=http://www.codeave.com"> Quote Link to comment https://forums.phpfreaks.com/topic/90809-redirect-to-thankyou-page/#findComment-466047 Share on other sites More sharing options...
haku Posted February 13, 2008 Share Posted February 13, 2008 Like I say, you can afford to ignore the minority if you are making amateur sites. I unfortunately don't have that freedom. Although that requirement also makes me learn to program properly instead of easily. As for as not having javascript turned on, in my company none of us do - company requirement due to security reasons. Quote Link to comment https://forums.phpfreaks.com/topic/90809-redirect-to-thankyou-page/#findComment-466050 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.