0

I have a link and when the user clicks it, it takes them as follows:

header('Location: www.mysite.com/part2.php');

I would instead like to take the user to part1.php for a couple of seconds before taking them to part2.php. User clicks, part1.php is visited for a few seconds, then part2.php is visited. part1.php is used as a gateway so it somehow has to know the request came from the link to pass over to part2.php Is this possible?

Sam Kingston
  • 817
  • 1
  • 10
  • 19
  • What moment do "few seconds" start from? – zerkms Oct 01 '15 at 01:31
  • from the time initial link is clicked on – Sam Kingston Oct 01 '15 at 01:36
  • What if "few seconds" is not enough for a page to load? – zerkms Oct 01 '15 at 01:38
  • I need just enough time for the page to load. I can't do the things stated below, because I need some kind of id tag as part1.php will be used for many passthroughs. – Sam Kingston Oct 01 '15 at 01:39
  • What is "just enough time for the page to load", in terms of seconds for an arbitrary client? – zerkms Oct 01 '15 at 01:40
  • Timing is not an issue at this time. Is the concept possible? – Sam Kingston Oct 01 '15 at 01:41
  • It is an issue: provide the technical definition on *WHEN* the redirect must happen, since it affects on *HOW* it would be done. – zerkms Oct 01 '15 at 01:41
  • Let's say when the page loads. I checked to see if this is a duplicate. Sorry I didn't state the question in enough depth. This is not a duplicate of that. – Sam Kingston Oct 01 '15 at 01:43
  • "Page load" even only exists in a user's browser, which means the only solution is to put a JS that will perform a redirect. – zerkms Oct 01 '15 at 01:43
  • There is a solution that you are suggesting below, but it doesn't consider some kind of id to mention where the request came from. Is this possible as I am using part1.php for many different requests depending on where the link originated. – Sam Kingston Oct 01 '15 at 01:46
  • That's why I asked about a moment in time. As per your latest statement "at a page load" - it's only possible to do with JS. If you need an id to be passed - pass it as a part of the url. – zerkms Oct 01 '15 at 01:46
  • Can you point me in the right direction for how to place the id. I have very limited knowledge. – Sam Kingston Oct 01 '15 at 01:48
  • `?id=42` then read it from `$_GET['id']` – zerkms Oct 01 '15 at 01:49
  • so I place the id on the link, get the id from part1, if it matches, send it to part2? – Sam Kingston Oct 01 '15 at 01:53

2 Answers2

1

This is possible using JS. Put the code below on part1.php

setTimeout(function () {
  location.href = 'part2.php';
}, <delay in milliseconds>);
orlland
  • 1,256
  • 8
  • 12
  • Part 1 will be used for other things to pass through, so I can't put it in part1 unless some id is passed through to let it know where it came from. – Sam Kingston Oct 01 '15 at 01:33
  • The other logic like if some id has been passed is not part of the question anymore. This is just a snippet that you can put in part1.php if you would like to redirect with delay. – orlland Oct 01 '15 at 01:39
  • Agree, I will award points to you and whoever answers the modified question as soon as it is answered. Thanks. – Sam Kingston Oct 01 '15 at 01:44
  • Hi Orland, Is there any way you could show me how to do this with an id passed to check where the request came from? – Sam Kingston Oct 01 '15 at 01:48
  • You can do it in PHP or JS if the ID is passed as URI parameter (http://stackoverflow.com/questions/979975/how-to-get-the-value-from-the-url-parameter) – orlland Oct 01 '15 at 02:12
0

Short answer... no.

Long answer. You will need to issue the redirect in part 1 to redirect then to page 2. You can do so using the meta redirect tag, or using a javascript timer on page 1, so that page 1 is visible on the browser before the page 2 appears.

See here for how to use meta refresh...https://en.m.wikipedia.org/wiki/Meta_refresh

iWantSimpleLife
  • 1,944
  • 14
  • 22