Page Redirect based on Condition

Throughout my site I have a couple different signup forms for a newsletter. I have created a thank you page for all those signups.
From the thank you page I am trying to create a redirect command to a new page based on what page/form (each page having a different form.) they signed up on.
I would like it to be timed so they can see and read one short line on the page saying “thanks for signing up” before being redirected.
I am open to suggestions using php,java or multiple meta redirects. I have not yet created any code because know what the command would be for sending a redirect based on the page they came from or form they signed up.

A common way of doing this is to load the thankyou page with a querystring of where the redirect is going to go.
http://www.domain.com/thankyou.php?return=shoppinglist.php

Then, the thankyou.php page sets a timed meta-redirect to the place in the querystring.


$location = filter_input(INPUT_GET, 'return', FILTER_SANITIZE_URL);
echo '<meta http-equiv="refresh" content="10;url=http://' + $_SERVER['PHP_HOST'] + '/' + $location + '">';

I’m not in a position to test as of this moment, but something like that does the job.

thank you for the reply,
So let me try to understand the flow. Where would the thankyou.php come into play? Sorry as I am a little unfamiliar with the coding you listed. I send them to the thankyou.html page with code similar to what you posted and it relays to a thankyou.php with a query string that gives them a redirect to where i want them to go?

If you use thankyou.html then you won’t be able to use PHP to create the redirect. Instead, you will need to rely on JavaScript being available and use that to perform the redirect instead.

Using JavaScript for the redirect is not a good solution for this problem. It can do it, but nowhere near as well as when using server-side code such as PHP.

I would like to use the simplest and most effective way possible. If I use a thank you.php and redirect based on criteria, taking them straight to the redirect it would be fine. I would however like to have them see some kind of “thank you” page because I would like them to see that I am greatful but also to let them know that they need to confirm the sign up through an automatic email that is sent out once they submit their details.

The content attribute of the http-equiv refresh is made up of two parts separated by a semicolon. The number of seconds to wait, and the url to load.
It will wait for the number of seconds before loading the url.

Do you see the 10 (for 10 seconds) in the example I gave?