Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Feb 2014
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    HTML page only to be hit once

    Hi, im new here so please be nice

    Im wondering if there is a way to make a HTML page which can only be hit once. Basically, I want to see if its viable to run a competition to win tickets to a show, where by the user would have to find an object on the website, which can then be clicked on, taking them to claim their tickets. However, for obvious reasons I only want this link to work once and then maybe re-direct everyone else to a "try again soon" page. I have a few ideas, but stuck on the execution.

    An idea I had was a hit counter with a PHP if condition. Basically if the hit counter is at 1. then redirect to the try again page.

    Any idea, or am I clutching at straws.


    Thanks in advance,
    M

  • #2
    Regular Coder
    Join Date
    Jul 2012
    Location
    London
    Posts
    473
    Thanks
    4
    Thanked 86 Times in 86 Posts
    This is more PHP, should be moved!

    Try sessions;
    PHP Code:
    if(!isset($_SESSION['mypage_view'])
    {
         
    $_SESSION['mypage_view'] = 1;   
    } else {
         
    //check if this is not the first time the page has been viewed
         
    if(isset($_SESSION['mypage_view'])) {
          
    //not first time redirect
          
    header('location: google.com');
          
    session_write_close();
          exit();
         }

    Source: cookies - how do I show a php page just once only per user - Stack Overflow


  •  

    Posting Permissions

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