By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,024 Members | 1,945 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,024 IT Pros & Developers. It's quick & easy.

How can I redirect to "Thank You" page?

Haitashi
P: 96
Users register on my page. It's a multi-page form.

After my insert statement, I have the following code:

[PHP]if(!$insert){
die("There's little problem: ".mysql_error());
}

echo "Thank you for registering. Please check your inbox for your registration confirmation email.";[/PHP]

Instead of echoing that, I want to redirect the user to a thank you page.
Any ideas? Help is greatly appreciated.
Jul 19 '07 #1
Share this Question
Share on Google+
6 Replies


P: 3
Users register on my page. It's a multi-page form.

After my insert statement, I have the following code:

[PHP]if(!$insert){
die("There's little problem: ".mysql_error());
}

echo "Thank you for registering. Please check your inbox for your registration confirmation email.";[/PHP]

Instead of echoing that, I want to redirect the user to a thank you page.
Any ideas? Help is greatly appreciated.
This is one option:
Expand|Select|Wrap|Line Numbers
  1. if(!$insert){
  2. die("There's little problem: ".mysql_error());
  3. }
  4.  
  5. require "thankyou.htm";
Jul 19 '07 #2

Haitashi
P: 96
Thanks but that didn't work for me. Can't I direct the user to a URL?
Jul 19 '07 #3

mwasif
Expert 100+
P: 801
Use header() for this purpose.
[PHP]if(!$insert){
die("There's little problem: ".mysql_error());
}

header("Location: thankyou.html");
exit;[/PHP]
Make sure there should not be any output before header().
Jul 19 '07 #4

Atli
Expert 5K+
P: 5,058
Use header() for this purpose.
[PHP]if(!$insert){
die("There's little problem: ".mysql_error());
}

header("Location: thankyou.html");
exit;[/PHP]
Make sure there should not be any output before header().
This is of course be the best way, and should be used if at all possible. (Tho the exit() call is kind of redundant.)

But if you absolutely can not hold of outputting before the redirect, you can always use this javascript trick:
Expand|Select|Wrap|Line Numbers
  1. echo '<script type="text/javascript">location.href="thankyou.html";</script>';
  2.  
Jul 19 '07 #5

gregerly
Expert 100+
P: 192
or use an output buffer
Jul 19 '07 #6

Haitashi
P: 96
Awesome!

Thanks guys. I used this:

Expand|Select|Wrap|Line Numbers
  1. if(!$insert){
  2. die("There's little problem: ".mysql_error());
  3. }
  4.  
  5.  
  6. echo '<script type="text/javascript">location.href="http://www.google.com";</script>';
Of course I'm not gonna use Google, but I just wanted to make sure it worked ^_^.
Jul 19 '07 #7

Post your reply

Sign in to post your reply or Sign up for a free account.