Return to referring page
Greetings:
I have a shopping cart script that when the user clicks the add button, a subroutine runs that opens up the tabulation file and adds the appropriate items. It then returns the user to the cart page, or displays the tabulation page, depending on a redirection variable that I set to 1 or 0 in my configuration file. It accomplishes the redirection through the JavaScript history.back function. The problem with this is that the user usually sees a brief shot of the tabulation page just before being redirected. This is disturbing to some users, and confusing to a user that has a slow connection. I would like to rplace the JavaScript function with a PERL statement that accomplishes the same goal; the user stays on the shopping page until they are ready to checkout. Any code change that would accomplish this is greatly appreciated. Please see below for existing code:
code:
if ($useredirect eq '1') { print "Content-type: text/html\n\n <html><body bgcolor=\#ffffff onload=\"history.back()\">\n"; } else { &review_items; } [/code]
Rob Pengelly posted this at 20:34 — 1st December 1999.
They have: 850 posts
Joined: Jul 1999
Hmm, not sure if I understand this completely, but here goes nothing
$lasturl=$ENV{'HTTP_REFERER'};
#put this in when the user is at the URL you want them to be when they are redirected later on.
if ($useredirect eq '1')
{print "Location: $lasturl";}
else{}
Try that, if it doesn't work sorry
------------------
If you counted 24 hours a day, it would take 31,688 years to reach one trillion.
[This message has been edited by robp (edited 01 December 1999).]
http://www.thehungersite.com - http://www.therainforestsite.com
http://www.ratemymullet.com - Beauty is only mullet deep.
aconite posted this at 22:07 — 1st December 1999.
They have: 8 posts
Joined: Oct 1999
Thanks for your help rob. I tried your simple fix that calls the environment variable, but I get premature end of script header error. I ran the edited script against a debugger that my ISP provides, and it doesn't show any problems, but then again it might just be a syntax checker. I was also thinking about putting something like:
Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.