Show Support Email Address To First Page Visitor Only

Discussion in 'PHP' started by ArchAxis, Feb 18, 2013.

  1. #1
    Hi, I'm trying to figure out how to display an email address for the first visitor of a page and hide the email address from everyone else. The page is created by the first visitor via a form and I want them to see an email address only meant for their eyes only.

    I've tried using PHP Session variables but that doesn't work, I was thinking cookies would be the best bet but I wanted some opinions.

    Any help would be great, Thanks!
     
    Solved! View solution.
    ArchAxis, Feb 18, 2013 IP
  2. #2
    You can't use session variables nor cookies, as they work at a client level (for all visitors).

    You need to create a file on your server the first time the script runs, and check if the file exists then.

    if(!file_exists("showed.txt"){
        echo "your@email.com";
        file_put_contents("showed.txt","showed");
    }
    Code (markup):
    This file will exist on your server and once created, the email will no longer be shown.
     
    Automagick, Feb 18, 2013 IP
    ArchAxis likes this.
  3. ArchAxis

    ArchAxis Well-Known Member

    Messages:
    136
    Likes Received:
    11
    Best Answers:
    1
    Trophy Points:
    175
    #3
    Your solution is brilliant, works like a charm! Thank you, you're a genius!!
     
    ArchAxis, Feb 18, 2013 IP