|
|
Viewing Topic: Go back link |
TracNav |
Subject: "Go back link"
Posted: @ 9:38 am on Mar 24 2008 |
|
|
Member #: 629 Rank: User - (11) Since: 03/15/08 Posts: 11 From: Wokingham, UK.
|
Simply, I need
a link that
will act as a
go back to the
referring page.
I have a
shopping cart,
and want the
user to be able
to go back to
browsing the
products page
after entering
an item. The
problme is, I
have an
updating
function when
the user
manually
changes the
quantity of an
item in the
cart - when
they try to go
back, it
performs the
same task
again, adding
another item to
the
purchase.
I cant just use
a link as I
have many
different
product pages,
and they need
to go to the
right one!
I'd post up
some of the php
Ive been
trying, but I
wrote it and
it'll be
embarassing
Thanks, Trac.
When replying
please bear in
mind the severe
simplicity of
my brain.
Thanks. |
Viewed: 8,440 Times | |  |
TracNav |
Subject: "re: Go back
link"
Posted: @ 9:56 am on Mar 24 2008
|
|
|
Member #: 629 Rank: User - (11) Since: 03/15/08 Posts: 11 From: Wokingham, UK.
|
Ok, I cant
actually see
whats wrong so
here is my code
[note, Ive only
tried to
redirect to
products.php
for now to keep
it simple].
Code:
(At top of
page)
$lasturl =
$_SERVER['HTTP
_REFERER'];
(In HTML)
<?php
if
(strpos('produ
cts.php',$last
url)) {
echo
'<p><
a
href="jav
ascript:history
.go(-1)"
title="Re
turn to the
previous
page">
« Go
back</a>&
lt;/p>';
} else {
echo
'<p><
a
href="htt
p://a51.seemepl
ayme.net/ben/pr
oducts.php&quo
t;
title="Pr
oducts"&g
t;«
Go back to
products</a&
gt;</p>'
;
}
?>
Problem here is
that even if I
did come from
products.php it
will still
display the
link with
"go back
to
products"
. Any ideas /
suggestions?
When replying
please bear in
mind the severe
simplicity of
my brain.
Thanks. |
Viewed: 8,433 Times | |  |
bs0d |
Subject: "re: Go back
link"
Posted: @ 2:58 pm on Mar 24 2008
|
|
|
 Member #: 1 Rank: Admin. - (1,505) Since: 02/06/05 Posts: 600 From: USA
|
Did you just
try using
Javascript? It
would take them
to the previous
page visited,
like this:
<a
href="jav
ascript:
history.go(-1)
">Back&
lt;/a>
|
Viewed: 8,423 Times | |  |
TracNav |
Subject: "re: Go back
link"
Posted: @ 1:15 pm on Mar 27 2008
|
|
|
Member #: 629 Rank: User - (11) Since: 03/15/08 Posts: 11 From: Wokingham, UK.
|
Yeah Ive tried
that, but
ofcourse if a
user adds a
quantity the
'back' will
make it add
that again. Im
not very good
at explaining,
so try here:
http://a51.seem
eplayme.net/ben
/shophome.php.<
br />
Add an item to
the cart, then
change the
quantity and
press 'update
cart'. Ive
changed the
link to
'continue
shopping' for
the moment.
Imagine, if
there was a
'go back' it
would do the
update again,
adding more
items to the
cart and not
taking you
back.
Sorry 
When replying
please bear in
mind the severe
simplicity of
my brain.
Thanks. |
Viewed: 8,381 Times | |  |
bs0d |
Subject: "re: Go back
link"
Posted: @ 2:01 pm on Mar 27 2008
|
|
|
 Member #: 1 Rank: Admin. - (1,505) Since: 02/06/05 Posts: 600 From: USA
|
One thing you
might end up
doing is in
your code to
add an item,
check the inbox
to see if the
item already
exists. If it
does, prompt to
add again
(increase
quantity by X)
or cancel (do
not add item).
|
Viewed: 8,376 Times | |  |
TracNav |
Subject: "re: Go back
link"
Posted: @ 8:05 pm on Mar 27 2008
|
|
|
Member #: 629 Rank: User - (11) Since: 03/15/08 Posts: 11 From: Wokingham, UK.
|
But this still
doesnt solve
the problem
I'll keep a
'continue
shopping' link
until Ive
rummaged around
and found an
answer. If I
find one, I'll
post a
solution.
One thought was
a
javascript:hist
ory.go(- number
defined by how
many times
update function
has been called
), though Im
not sure how to
do it - or even
if its possible
with javascript
and php 
When replying
please bear in
mind the severe
simplicity of
my brain.
Thanks. |
Viewed: 8,361 Times | |  |
Viewing Page: 1 of 1 |
|
|
|