Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Page 1 of 3 1 2 3 LastLast
Results 1 to 10 of 29
  1. #1
    Senior Member tekp's Avatar
    Join Date
    Jan 2004
    Location
    A small village near a small city near a small cit
    Posts
    918
    Member #
    4667
    Liked
    1 times
    Can I detect, using PHP, that a user has refreshed the page?

    It's for use on my contact form. I have one file, index.php, which deals with each stage of the contact process by a series of "if this is true then show this page" and so on. For this reason, I can't simply check if the URL is the same as the previous URL, because it is anyway, as it's always the same file.

    Is there any way to specifically detect if a user has refreshed the page?

    I need to do this so that certain people can't get to the end of the sending process and simply keep hitting F5 and spamming me...

    Thank you ^-^
    tekp :cheeky: tekponline.com

  2.  

  3. #2
    Senior Member
    Join Date
    May 2003
    Location
    UK
    Posts
    2,354
    Member #
    1326
    Yeah, there is a way.

    You could simply have a hidden field, when the contact page is first displayed, lets say it's value is 1. Then, when they submit the form, you increment the form field to 2. (Or any value).

    So, whenever the field is 2 (or the value you choose) you know the form has been submitted.

    Wait: I thought you meant check if the form is submiited

  4. #3
    Senior Member tekp's Avatar
    Join Date
    Jan 2004
    Location
    A small village near a small city near a small cit
    Posts
    918
    Member #
    4667
    Liked
    1 times
    I meant check to see if they'd refreshed the last page...

    But wouldn't that work anyway? Because if they'd refreshed the page there wouldn't be a $_POST or a $_GET value for the hidden field? Unless they allowed the browser to repost the information :/
    tekp :cheeky: tekponline.com

  5. #4
    Senior Member
    Join Date
    May 2003
    Location
    UK
    Posts
    2,354
    Member #
    1326
    I think it would work yeah..

    You do something like, if index.php?id=contact then display the contact page. if index.php?id=about then display then display the contact page and so on, right?

  6. #5
    Senior Member tekp's Avatar
    Join Date
    Jan 2004
    Location
    A small village near a small city near a small cit
    Posts
    918
    Member #
    4667
    Liked
    1 times
    Nope, there's three different 'pages'.

    The first one just comes up when everything is normal and the file is visited for the first time.

    The second one comes up when $_POST exists ('cause there's a form with action="post" on the previous page that's submitted to the file itself). This second page contains a hidden form input that is called 'send', the value of which is 'true'.

    The third page comes up when $_POST['send'] == true.

    :/
    tekp :cheeky: tekponline.com

  7. #6
    Senior Member raspberryh's Avatar
    Join Date
    Aug 2004
    Location
    Erie, PA
    Posts
    882
    Member #
    7208
    Liked
    1 times
    Hmm, you could use a session variable... In the code where you actually do the emailing of the form info, include a line like
    PHP Code:
    $_SESSION['sent'] = true
    and check for that when sending. Like this:
    PHP Code:
    if(!$_SESSION['sent']){
      
    mail(...);
      
    $_SESSION['sent'] = true;

    choosy developers choose gif!
    website | paintings | blog

  8. #7
    Senior Member tekp's Avatar
    Join Date
    Jan 2004
    Location
    A small village near a small city near a small cit
    Posts
    918
    Member #
    4667
    Liked
    1 times
    So session variables... how long are they stored for...?

    (And thanks I shall try ^-^)
    tekp :cheeky: tekponline.com

  9. #8
    Member tlcook's Avatar
    Join Date
    Nov 2006
    Posts
    38
    Member #
    14386
    For the session... I.e until you close the browser.

  10. #9
    Senior Member tekp's Avatar
    Join Date
    Jan 2004
    Location
    A small village near a small city near a small cit
    Posts
    918
    Member #
    4667
    Liked
    1 times
    So surely if the user wanted to click Contact Me again and try to send another contact message the session variable was still there and the script wouldn't let them? aranoid:
    tekp :cheeky: tekponline.com

  11. #10
    Member tlcook's Avatar
    Join Date
    Nov 2006
    Posts
    38
    Member #
    14386
    Indeed. So what you want is a timeout cookie then? More like flood protection?


Page 1 of 3 1 2 3 LastLast

Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

Search tags for this page

check page refresh php

,
detect page refresh in php page
,
detect refresh in php
,
how to detect if a user refresh pages using php
,
how to detect if a web page is refreshed
,
if page refresh php
,
php check refresh
,
php detect page refresh
,

php detect refresh page

,
php detecting refresh was done
Click on a term to search for related topics.
All times are GMT -6. The time now is 09:24 PM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com