473,396 Members | 1,990 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

How can I redirect to "Thank You" page?

Haitashi
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
6 3329
juro
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
Thanks but that didn't work for me. Can't I direct the user to a URL?
Jul 19 '07 #3
mwasif
802 Expert 512MB
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
5,058 Expert 4TB
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
192 Expert 100+
or use an output buffer
Jul 19 '07 #6
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

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

Similar topics

3
by: Rob Meade | last post by:
Hi all, Ok - probably really obvious and something I'm clearly missing...but ... I have a form with 3 areas for text to be entered, the form has some validation controls, upon it being...
7
by: Larry Bud | last post by:
More of a design question than technical.... combining Ajax technology with ASP... Top portion of the page contains several Select boxes which are dependant upon one another. Ajax handles that...
9
by: Alexandra | last post by:
Not sure why none of these permutations are working. I appreciate a second set of eyes! .... <form id="form1" name="form1" > .... <input name="Submit1" type="submit" tabindex="10"...
6
by: Brian L. Troutwine | last post by:
The heading comment to pprint reads: # This is a simple little module I wrote to make life easier. I didn't # see anything quite like it in the library, though I may have overlooked # ...
22
by: ZioMiP | last post by:
Hi to all... I'm actually using Tkinter for my GUI... but I need to "put a piece of a web-page in a widget" how can I do? which GUI module do you suggest me to use for do that? or which GUI...
1
by: yuva | last post by:
"Thank you for this amazing program. Within a weekend, my team increased with 50 new people joining. Every time I logged on there was a new affiliate. Absolutely amazing. " S. Horvath SOUTH AFRICA...
5
by: workingstiff19 | last post by:
I just want people to click on a link to download a file. I've done it before, but this is a new computer and I must be missing something. (Possibly an Apache configuration setting?) Here is...
4
by: Wolfman | last post by:
http://javascript.internet.com/img/new-to-you/new.gif Hi all Upon seeking to differentiate new content from old in an HTML list based upon when each user last visited, I began researching "new to...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.