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 10 of 10
  1. #1
    cub
    cub is offline
    New Coder
    Join Date
    Jan 2012
    Posts
    10
    Thanks
    3
    Thanked 0 Times in 0 Posts

    first time visitor welcome message

    Hi all new guy on the block here,

    I've got a website, and I want to add a welcoming message which hovers on a certain part of the page which only loads for the visitor for the first time they login, and won't again(presumably cookies used). And says something like "adjust your settings here.." I don't want it to be an external popup but something that loads on the page in a certain area, defined by me (PX-pixle reference)

    I think i nutted something out in a bit of PHP, this is what i've got so far
    PHP Code:
    <?php
        
    if (firstLogin()){
            
    genSpecial(***load jquerie or css etc***);
        }
        else{
            
    genRegular();
        }
    ?>
    can anyone help me figure out how to make this all work and load a box from jquerie or something similar? thanks
    David

  • #2
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,509
    Thanks
    8
    Thanked 1,090 Times in 1,081 Posts
    Make a <div> area where you wish it to be ...
    And then, use CSS to make the <div> "hidden", so it doesn't show.

    If the cookie does not exist, you make it "visible" ... if the cookie exists make it "hidden".
    You do this using inline CSS within that <div>.

    So, get the <div> part working first ... where you can switch it manually to test it.
    Then, when that's working, you'll add the PHP Cookie part to make it work automatically

    <style>
    .hidden{display:none;}
    .visible{display:block;}
    </style>


    <div class="visible">
    This is my div with the information I want to show.
    only when there is no cookie set for this computer.
    </div>


    After the cookie is set, you'll be changing it to this ...


    <div class="hidden">
    This is my div with the information I want to show.
    only when there is no cookie set for this computer.
    </div>



    .

  • The Following 2 Users Say Thank You to mlseim For This Useful Post:

    cub (01-08-2012), intensive (01-09-2012)

  • #3
    cub
    cub is offline
    New Coder
    Join Date
    Jan 2012
    Posts
    10
    Thanks
    3
    Thanked 0 Times in 0 Posts
    Hi
    Thanks for that, I was hoping to not use cookies, sorry for not making this clear, just incase the user goes on another computer etc, I want it only to appear oncer per an account, thats where i was going to use PHP, how would I do this?
    Thanks for everything though
    David

  • #4
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,509
    Thanks
    8
    Thanked 1,090 Times in 1,081 Posts
    You'll have to add a new column to the user's MySQL table.
    Maybe you can call it "new_user", and put a 1 in there when
    the user is new. After they view the special part, you put a 0 in
    that column. Check that column each time to see if the logged-in
    user has seen it or not.

  • #5
    New to the CF scene
    Join Date
    Sep 2011
    Location
    West Coast
    Posts
    5
    Thanks
    1
    Thanked 0 Times in 0 Posts
    I am building a new site and would not mind doing this, so I will give this a try and report back if I get it done.

    Thanks

  • #6
    Senior Coder
    Join Date
    Jul 2011
    Posts
    1,226
    Thanks
    3
    Thanked 171 Times in 171 Posts
    http://www.codingforums.com/showthread.php?t=247725

    My answers in this thread are of relevance to you - they pretty much answer your question.
    Useful function to retrieve difference in times
    The best PHP resource
    A good PHP FAQ
    PLEASE remember to wrap your code in [PHP] tags.
    PHP Code:
    // Replace this
    if(isset($_POST['submitButton']))
    // With this
    if(!empty($_POST))
    // Then check for values/forms. Some IE versions don't send the submit button 
    Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live.

  • #7
    cub
    cub is offline
    New Coder
    Join Date
    Jan 2012
    Posts
    10
    Thanks
    3
    Thanked 0 Times in 0 Posts
    Hi
    Thanks all, it's not a one user site, but more of a multi user social network, similar to facebook if you will, thats where I was thinking of adding that little script into the index.php page when they first login, but i'm not so sure on how to load querie with it... any pointers?
    Thanks again
    David

  • #8
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,509
    Thanks
    8
    Thanked 1,090 Times in 1,081 Posts
    Did you add a new column to the database table (where your user stuff is)?
    Each user needs a spot where you know if they've seen the welcome message or not.
    When a new user is added to the table, you put a 1 in that spot (did not see the message).
    When they see the welcome message, you update that to a 0 (they saw the message).

  • #9
    cub
    cub is offline
    New Coder
    Join Date
    Jan 2012
    Posts
    10
    Thanks
    3
    Thanked 0 Times in 0 Posts
    Hi
    Sorry for not making myself clear, I am trykng to set it up, so I don't have to do anything, because there are quite a few new members everyday and I could spend all day just updating the mysql tables. Is there a solution in PHP etc?
    thanks

  • #10
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,509
    Thanks
    8
    Thanked 1,090 Times in 1,081 Posts
    Well no ...

    You add a column to the table ... that's one MySQL command.
    You can do that using your MySQL admin panel (on your webhost control panel).

    Then, you add the starting value of 1 to that column when they register.
    And after they see the welcome, you do an UPDATE to that column ... a zero.
    It's done with scripting, so you do nothing.

    Only the members who have a 1 there will see the welcome, so all previous
    members are past it already ... they won't see it.

    We can't do any scripting ... we don't have access to your database or files.
    Maybe you can find a person who lives by you that can stop over and show
    you in person. Or, you'll have to trust a stranger to enter your files.


  •  

    Tags for this Thread

    Posting Permissions

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