Forum Moderators: coopster

Message Too Old, No Replies

History with php tag?

Want to create redirection with -1 history

         

Twisted Mind

7:57 am on Nov 18, 2005 (gmt 0)

10+ Year Member



hi i would like to know if there is a possiblillity to get php to do redirect the user of the site back 1 history...

Anyango

8:36 am on Nov 18, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Just for fun

<?
echo "<script language=javascript>history.back(1);</script>";
?>

;)

I am sure that's not what you want ;)

Anyango

8:42 am on Nov 18, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



What about this one? core PHP ;) (it's not any gauranteed method, it just came in mind on the fly)

<?
if ($_SERVER[HTTP_REFERER])!="")
{
header("Location:".$_SERVER[HTTP_REFERER]);
}
?>

Logically, this should work. didn't check practically though.

Twisted Mind

8:54 am on Nov 18, 2005 (gmt 0)

10+ Year Member



I have another idea... this will be send with a form what if have something in the form like <input type = hidden value ="urlofthepagiamat" name="thispage">

Twisted Mind

8:58 am on Nov 18, 2005 (gmt 0)

10+ Year Member



if i try your script it says:
Parse error: syntax error, unexpected T_IS_NOT_EQUAL in D:\Fluke_Mambo\administrator\components\com_managers\updatefromfrontend.php on line 25

sorry but i cant use javascript on this one (to first replyer)

Twisted Mind

8:59 am on Nov 18, 2005 (gmt 0)

10+ Year Member



u needed to delete 1)

Twisted Mind

9:01 am on Nov 18, 2005 (gmt 0)

10+ Year Member



it works but not like i want becouse it links back to index.php
not to :
index.php?page=checkout.index&ssl_redirect=0&option=com_phpshop&Itemid=26

Anyango

9:07 am on Nov 18, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Yah sorry i had double quotes missing and an extra )in variable name. hmm lets wait and see what experts say.

Anyango

9:17 am on Nov 18, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Good question though. never needed to do it with php, now i wonder even if it's possible with php? though it should be but not something i am aware of. curiously waiting to hear from php gurus. ;)

Twisted Mind

9:19 am on Nov 18, 2005 (gmt 0)

10+ Year Member



It is possible but i dont know exactly how maybe with a #*$!tion but i dont know functions :p

Twisted Mind

10:35 am on Nov 18, 2005 (gmt 0)

10+ Year Member



anyone?

Iguana

10:54 am on Nov 18, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



it links back to index.php

You have all the other variables in your GET array so you can build the full pagename + querystring to redirect back to

Twisted Mind

11:31 am on Nov 18, 2005 (gmt 0)

10+ Year Member



lol and how :p

Receptional Andy

11:45 am on Nov 18, 2005 (gmt 0)



<?
if ($_SERVER[HTTP_REFERER])
{
header("Location: ".$_SERVER[HTTP_REFERER]);
}
?>

This should work and also preserve the query string. If I clicked onto a page with the code above from /index.php?foo=bar, I will be redirected to /index.php?foo=bar

Is that not what you need to achieve?

Twisted Mind

12:02 pm on Nov 18, 2005 (gmt 0)

10+ Year Member



yep

Twisted Mind

12:18 pm on Nov 18, 2005 (gmt 0)

10+ Year Member



but it just links back to index.php but the address bar says
*/index.php?page=checkout.index&ssl_redirect=0&option=com_phpshop&Itemid=26

Receptional Andy

12:20 pm on Nov 18, 2005 (gmt 0)



The address bar simply displays the URL the visitor is on - why do you think it is sending them to /index.php (no variables) - is this because something isn't processed on the page?

Nutter

1:09 pm on Nov 18, 2005 (gmt 0)

10+ Year Member



What about...

Keep a session variable of the pages that are visited. Ex: $_SESSION['currentpage'] & $_SESSION['prevpage']. When a visitor goes from index.php?page=2 from index.php?page=1,?page=1 gets moved from 'currentpage' to 'prevpage' and?page=2 gets put into 'currentpage'. Then, just link to $_SESSION['prevpage'].

Twisted Mind

1:23 pm on Nov 18, 2005 (gmt 0)

10+ Year Member



?
sorry i dont know how to do that :P i know #*$! about sessions

Iguana

1:25 pm on Nov 18, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I'm at work so no access to php to test this - but how about this:

header('Refresh: 1,URL="'.$_SERVER['HTTP_REFERER'].'"');

Twisted Mind

1:28 pm on Nov 18, 2005 (gmt 0)

10+ Year Member



im working too :p

Twisted Mind

1:45 pm on Nov 18, 2005 (gmt 0)

10+ Year Member



doesnt work only creates undentified variables :P

Nutter

3:52 pm on Nov 18, 2005 (gmt 0)

10+ Year Member



You may also run in to problems of blank referrers - some security software I believe blanks it out.