Results 1 to 9 of 9
  1. #1
    ABW Ambassador AddHandler's Avatar
    Join Date
    January 19th, 2005
    Posts
    1,270
    Show Text One Time via PHP
    I am having luck today with all the great help!
    So I thought I would push it a little...


    I want to show some text - BUT - I only want to show it one time
    not every time the page is loaded by the same visitor..
    SALES TEXT - to make it seem a little more urgent...

    Any way to do this via PHP..
    will it require cookies to be set - or - ip logged...???

    I am working on an older site upgrading it to include some PHP..
    any help would be appreciated..


    THANKS!

  2. #2
    Not Verif-Lidated infoTim's Avatar
    Join Date
    January 18th, 2005
    Location
    Sunny Florida
    Posts
    1,021
    Setting a cookie is about the best way to go. You can't do it by IP because a lot of people (*cough* AOL) surf behind caching proxies and the IP is not reliable.

    - Tim
    Tim
    consultant by day, affiliate by night

  3. #3
    Full Member
    Join Date
    January 18th, 2005
    Location
    UK
    Posts
    273
    Have a read about PHP sessions


    http://php.net/session
    http://www.phpfreaks.com/tutorials/41/0.php

    I have used PHP session to build a custom shopping cart for a client and
    it was pretty straight forward.

    So it should be only a few lines of PHP to do what yu want without having to fuss around with cookie code.

    Les

  4. #4
    Not Verif-Lidated infoTim's Avatar
    Join Date
    January 18th, 2005
    Location
    Sunny Florida
    Posts
    1,021
    It's still using cookies under the hood. :-)
    Tim
    consultant by day, affiliate by night

  5. #5
    ABW Ambassador AddHandler's Avatar
    Join Date
    January 19th, 2005
    Posts
    1,270
    Yea sounds great - But I am not a PHP guru..

    I just mess with it from time to time and I know a little bit but most of my stuff is cut and paste... so that is what I was looking for, something short and sweet...
    I looked at those pages and I may be able to do it myself. BUT it looks a little more complicated than anything I have ever done myself... The problem I see is that I want it to show on every page of my site -- but only once..
    No better time to learn PHP than right now - huh..??
    I guess I'll give it a go..

    I have some javascript that pops a window ONE TIME based on a cookie..
    BUT I hate pop-up windows and I don't use them..
    maybe I could look at that and see if I can rework the script so it shows HTML instead of popping a window..



    Thanks!

  6. #6
    Not Verif-Lidated infoTim's Avatar
    Join Date
    January 18th, 2005
    Location
    Sunny Florida
    Posts
    1,021
    to set a cookie that expires a year from now:

    SetCookie("MYCOOKIE","yum",time()+31536000,"/");

    to see if it's set:

    if ($_COOKIE['MYCOOKIE']=="yum") {
    ...
    }
    else {
    ...
    }

    to erase it:

    SetCookie('MYCOOKIE', "", 0, "/");
    Tim
    consultant by day, affiliate by night

  7. #7
    Newbie
    Join Date
    April 5th, 2005
    Location
    Dallas, Texas
    Posts
    35
    SuZe,

    I think maybe this is what you're getting at...

    "How to dynamically load any html file component"
    http://www.cryer.co.uk/resources/javascript/script4.htm

    It deals with creating a division (using <div> of course) and then loading things into it based on whim. You would set a cookie to see if it's the first time and put the sale info, and all other times put something else.

    Hope this helps,

    Wesley

  8. #8
    Member
    Join Date
    January 18th, 2005
    Posts
    145
    remember that now a lot of browsers, toolbars, and add-ons allow the visitor to have more direct control of when and/or if a cookie is accepted.

    so you want to make sure that visitors which may have automatically rejected an unknown cookie when they received an alert about it, have a second chance to create a cookie once they *KNOW* what the cookie is used for.

    something along the lines of the "close [x]" link which you may find in non-pop-up pop-up ads (the ads which pop-up over the text of the page itself, not in a new browser window).

    an idea would be to perform the cookie check once when the page is first loaded, then a *SECOND* time as the snipplet is loaded, and if the cookie isn't there when the snipplet is loaded, then add a "Don't Show This Message Again [x] - requires cookies" option to the snipplet.

  9. #9
    Sgt. Joe Friday frank3iii's Avatar
    Join Date
    January 18th, 2005
    Posts
    441
    Another option would be to show a random sales message every time a page was loaded.

    The obvious benefit is that there is no cookie to worry about. A possible disadvantage is that you would have to write a bunch of slightly different sales messages.

    If you are coding with PHP as your server-side language you can find a lot of sample codes if you search around a little. Probably a lot of them that use Perl out there too.

  10. Newsletter Signup

+ Reply to Thread

Similar Threads

  1. Script (PHP?) to track IP and not show same content to same IP twice.
    By Hardaka in forum Programming / Datafeeds / Tools
    Replies: 10
    Last Post: February 15th, 2012, 01:37 PM
  2. Script to show customised text and images on a t-shirt?
    By Azam in forum Programming / Datafeeds / Tools
    Replies: 0
    Last Post: October 30th, 2006, 02:09 PM
  3. How to show record-level data in plain text on index pages??
    By jrbrunger in forum WebMerge (Fourthworld.com)
    Replies: 2
    Last Post: April 11th, 2006, 12:31 AM
  4. php+text site
    By ttxxtt8 in forum Programming / Datafeeds / Tools
    Replies: 1
    Last Post: August 11th, 2005, 11:45 AM
  5. Script to show text until $date
    By TJ in forum Programming / Datafeeds / Tools
    Replies: 3
    Last Post: November 23rd, 2004, 01:52 PM

Posting Permissions

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