PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > php.general > remove page referrer
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
remove page referrer

Réponse
 
LinkBack Outils de la discussion
Vieux 11/09/2007, 09h40   #1
Stut
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: [PHP] remove page referrer

Shahrzad wrote:
> I have 2 page ,when I go from first page to second page , I don't want the user can back to first page where it come from. is there any way to do this in php ? to remove or disactive $_SERVER["HTTP_REFERER"] in php?


No, this is not something the server (where PHP lives) can control.

Why do you think you need to do this?

-Stut

--
http://stut.net/
  Réponse avec citation
Vieux 11/09/2007, 10h05   #2
Aleksandar Vojnovic
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: [PHP] remove page referrer

You can not control this, but you might be able to control the page
where the user is going back through the third page

like this:

page 1: submit to page 2
page 2: header('Location: /page 3');
page 3: the final page

if the user clicks back he is going to end up on page 2 which has
location redirect to page 3. True?

-Xander

Stut wrote:
> Shahrzad wrote:
>> I have 2 page ,when I go from first page to second page , I don't
>> want the user can back to first page where it come from. is there any
>> way to do this in php ? to remove or disactive
>> $_SERVER["HTTP_REFERER"] in php?

>
> No, this is not something the server (where PHP lives) can control.
>
> Why do you think you need to do this?
>
> -Stut
>

  Réponse avec citation
Vieux 11/09/2007, 10h54   #3
Stut
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: [PHP] remove page referrer

Please include the list when replying.

Shahrzad wrote:
> Mercyyy Stut for your reply,


No problem.

> For the reason of sessions ,,,, I want no one can back to previous
> page,if somebody temptates to do that, either this error occur :
> "HTTP/1.0 404 Not Found" or that page reload again .
> Can I do this with javaScript or something else?


There are some nasty evil hacks that can achieve this, but you really
don't want to.

There are two possible solutions to your problem...

1) Write your code in such a way that it doesn't matter if someone goes
back to a previous page and resubmits it.

2) Use the session to keep track of what page the user is on. That way
if they do hit the back button you can tell them they've not allowed to
do that and provide a link to the page they should be one.

The first option is the best because the second is very poor UI design.

Is there a reason why the user cannot go back to a previous page? What
is technically stopping you handling that situation?

-Stut

--
http://stut.net/
  Réponse avec citation
Vieux 11/09/2007, 14h45   #4
brian
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: [PHP] remove page referrer

Shahrzad wrote:
> Hi all, I have 2 page ,when I go from first page to second page , I
> don't want the user can back to first page where it come from. is
> there any way to do this in php ? to remove or disactive
> $_SERVER["HTTP_REFERER"] in php?
>


Shahrzad, i'm assuming that you want to do this to protect against
duplicate form submissions. If that's the case, this article may be of
some use:

Redirect after POST
http://www.theserverside.com/tt/arti...irectAfterPost

brian
  Réponse avec citation
Vieux 11/09/2007, 14h52   #5
Daniel Brown
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: [PHP] remove page referrer

On 9/11/07, Stut <stuttle@gmail.com> wrote:
> Please include the list when replying.
>
> Shahrzad wrote:
> > Mercyyy Stut for your reply,

>
> No problem.
>
> > For the reason of sessions ,,,, I want no one can back to previous
> > page,if somebody temptates to do that, either this error occur :
> > "HTTP/1.0 404 Not Found" or that page reload again .
> > Can I do this with javaScript or something else?

>
> There are some nasty evil hacks that can achieve this, but you really
> don't want to.
>
> There are two possible solutions to your problem...
>
> 1) Write your code in such a way that it doesn't matter if someone goes
> back to a previous page and resubmits it.
>
> 2) Use the session to keep track of what page the user is on. That way
> if they do hit the back button you can tell them they've not allowed to
> do that and provide a link to the page they should be one.
>
> The first option is the best because the second is very poor UI design.
>
> Is there a reason why the user cannot go back to a previous page? What
> is technically stopping you handling that situation?
>
> -Stut
>
> --
> http://stut.net/
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


What about the following?

L> page1.php
<?
session_start();
if($_SESSION['already_submitted'] == True) {
header("Location: page2.php");
}
// Continue with your existing code from the first page.
?>

L> page2.php
<?
session_start();
$_SESSION['already_visited'] = True; // Set this now.
// Continue with the rest of your code from the second page.
?>

For as long as that session remains active, any time the user
attempts to reload that page, they'll be forwarded to a page of your
choice (in this case, page2.php). If you absolutely want a 404 error,
you can either spoof one or legitimately create one --- by forwarding
them to a page that does not and will not ever exist on your server.
Not a very elegant solution, but it will work.

--
Daniel P. Brown
[office] (570-) 587-7080 Ext. 272
[mobile] (570-) 766-8107

Give a man a fish, he'll eat for a day. Then you'll find out he was
allergic and is hospitalized. See? No good deed goes unpunished....
  Réponse avec citation
Vieux 11/09/2007, 16h26   #6
tedd
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: [PHP] remove page referrer

At 10:04 AM +0430 9/12/07, Shahrzad wrote:
>Hi all,
>I have 2 page ,when I go from first page to second page , I don't
>want the user can back to first page where it come from. is there
>any way to do this in php ? to remove or disactive
>$_SERVER["HTTP_REFERER"] in php?
>
>Thanks


Didn't someone recently ask this question?

In any event, from what you described above, try this below.

http://webbytedd.com/bb/one-time/

This uses sessions -- you cannot return to this page until you
restart your browser. It's a simple session variable check.

Cheers,

tedd

--
-------
http://sperling.com http://ancientstones.com http://earthstones.com
  Réponse avec citation
Vieux 11/09/2007, 19h16   #7
Ludovic André
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: [PHP] remove page referrer

Hi,
> You can not control this, but you might be able to control the page
> where the user is going back through the third page
>
> like this:
>
> page 1: submit to page 2
> page 2: header('Location: /page 3');
> page 3: the final page
>
> if the user clicks back he is going to end up on page 2 which has
> location redirect to page 3. True?

Nope, this ain't true: if he goes back, he'll land on page 1.
>
> -Xander

  Réponse avec citation
Vieux 11/09/2007, 19h48   #8
Daniel Brown
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: [PHP] remove page referrer

On 9/11/07, NOSPAM plz <bla> wrote:
> I think you have to put the exit(); function in the code to prevent hacks.
>
> if($_SESSION['already_submitted'] == True) {
> header("Location: page2.php");
> *exit();*
> }


Good call. I forgot to type that in there, but you're right. ;-)

--
Daniel P. Brown
[office] (570-) 587-7080 Ext. 272
[mobile] (570-) 766-8107

Give a man a fish, he'll eat for a day. Then you'll find out he was
allergic and is hospitalized. See? No good deed goes unpunished....
  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 23h27.


Édité par : vBulletin® version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,13182 seconds with 16 queries