Jump to content


send back to the page they came from


5 replies to this topic

#1 zoom4267

    Young Padawan

  • Members
  • Pip
  • 191 posts
  • Gender:Female
  • Location:USA

Posted 14 August 2008 - 06:14 AM

I have a game on mysite. they can get to the game from clicking on a button graphic that is on about 5 different pages on the site. after they loose i want them to go back to the page they came from. so if they clicked on a button on the home page, they should go back to the home page, if they clicked on a button from the about us page, they should go back to the about us page.

the code is php, is this possible, how can i do it.

here is the redirect as it is now

define("LOOSER_REDIRECT","http://www.site.com/coupon/redirect.php");

then it goes to this page

<meta http-equiv="Content-type" content="text/html; charset=UTF-8" />
    <link rel="prefetch" href="http://www.site.com/index.php" />
    <meta http-equiv="Refresh" content="0; url=http://www.site.com/index.php" />

thanks

Edited by zoom4267, 14 August 2008 - 06:15 AM.


#2 Blaatzorrr

    Young Padawan

  • Members
  • Pip
  • 24 posts
  • Gender:Male
  • Location:The Netherlands
  • Interests:Html,CSS,Javascript,PHP&amp;Mysql and more =)

Posted 14 August 2008 - 06:20 AM

To send them back to the page they came from you can use javascript :)
Like this :

<a onClick="java script:history.go(-1);">Go back!</a>


#3 rc69

    PHP Master PD

  • P2L Staff
  • PipPipPipPip
  • 3,827 posts
  • Gender:Male
  • Location:Here
  • Interests:Web Development

Posted 14 August 2008 - 11:40 AM

That's assuming they have JS enabled.

I'd recommend using $_SERVER['HTTP_REFERER'] to get the page they came from, but that can be blocked by certain anti-virus software. So my next recommendation would be to pass the page they came from as a variable in the url and get it from there.

#4 zoom4267

    Young Padawan

  • Members
  • Pip
  • 191 posts
  • Gender:Female
  • Location:USA

Posted 14 August 2008 - 11:42 AM

View Postrc69, on Aug 14 2008, 12:40 PM, said:

That's assuming they have JS enabled.

I'd recommend using $_SERVER['HTTP_REFERER'] to get the page they came from, but that can be blocked by certain anti-virus software. So my next recommendation would be to pass the page they came from as a variable in the url and get it from there.


Thanks rc but i have no idea how to do that. im not much of a coder.

Thanks

#5 dotSilver

    Young Padawan

  • Members
  • Pip
  • 32 posts

Posted 14 August 2008 - 04:35 PM

I never knew the http_referer global variable can be blocked by certain anti-virus. The two ways that rc69 says can be done like so.

<meta http-equiv="Refresh" content="0; url=<? print $_SERVER['HTTP_REFERER']; ?>" />

Or to pass the page they came from on the url, you can do the following.

<a href="domain.com/playgame.php&re=<? print $_SERVER['REQUEST_URI']; ?>">Play Game</a>

This would give the whole url after your domain, so say your about us page has the following url:

domain.com/index.php?page=aboutus

The re would be index.php?page=aboutus

To call this url when needed, you can use the following:

$_GET['re'];

//If you wanted to point to the url again when they lose, it would be similar to this (pretend your defined constant is already defined.)

header( 'Location:'. LOOSER_REDIRECT .'?re='. $_GET['re'] );

If you are unsure about php redirection (the above code) I suggest you read about it in the php.net documentation, but just note that the above is just to show you how you can accomplish what you are after.

#6 zoom4267

    Young Padawan

  • Members
  • Pip
  • 191 posts
  • Gender:Female
  • Location:USA

Posted 14 August 2008 - 04:46 PM

great thanks alot, yes, i have been doing some more reaserch on php





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users