Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 01-08-2012, 11:56 AM   PM User | #1
cub
New Coder

 
Join Date: Jan 2012
Posts: 10
Thanks: 3
Thanked 0 Times in 0 Posts
cub is an unknown quantity at this point
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
cub is offline   Reply With Quote
Old 01-08-2012, 05:41 PM   PM User | #2
mlseim
Master Coder

 
mlseim's Avatar
 
Join Date: Jun 2003
Location: Cottage Grove, Minnesota
Posts: 9,042
Thanks: 8
Thanked 1,029 Times in 1,020 Posts
mlseim has a spectacular aura aboutmlseim has a spectacular aura aboutmlseim has a spectacular aura about
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>



.
mlseim is offline   Reply With Quote
The Following 2 Users Say Thank You to mlseim For This Useful Post:
cub (01-08-2012), intensive (01-09-2012)
Old 01-08-2012, 11:44 PM   PM User | #3
cub
New Coder

 
Join Date: Jan 2012
Posts: 10
Thanks: 3
Thanked 0 Times in 0 Posts
cub is an unknown quantity at this point
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
cub is offline   Reply With Quote
Old 01-09-2012, 03:15 AM   PM User | #4
mlseim
Master Coder

 
mlseim's Avatar
 
Join Date: Jun 2003
Location: Cottage Grove, Minnesota
Posts: 9,042
Thanks: 8
Thanked 1,029 Times in 1,020 Posts
mlseim has a spectacular aura aboutmlseim has a spectacular aura aboutmlseim has a spectacular aura about
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.
mlseim is offline   Reply With Quote
Old 01-09-2012, 04:21 PM   PM User | #5
intensive
New to the CF scene

 
Join Date: Sep 2011
Location: West Coast
Posts: 5
Thanks: 1
Thanked 0 Times in 0 Posts
intensive is an unknown quantity at this point
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
intensive is offline   Reply With Quote
Old 01-09-2012, 04:32 PM   PM User | #6
BluePanther
Senior Coder

 
Join Date: Jul 2011
Posts: 1,226
Thanks: 3
Thanked 171 Times in 171 Posts
BluePanther is on a distinguished road
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 
Quote:
Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live.
BluePanther is offline   Reply With Quote
Old 01-09-2012, 11:31 PM   PM User | #7
cub
New Coder

 
Join Date: Jan 2012
Posts: 10
Thanks: 3
Thanked 0 Times in 0 Posts
cub is an unknown quantity at this point
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
cub is offline   Reply With Quote
Old 01-10-2012, 02:08 AM   PM User | #8
mlseim
Master Coder

 
mlseim's Avatar
 
Join Date: Jun 2003
Location: Cottage Grove, Minnesota
Posts: 9,042
Thanks: 8
Thanked 1,029 Times in 1,020 Posts
mlseim has a spectacular aura aboutmlseim has a spectacular aura aboutmlseim has a spectacular aura about
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).
mlseim is offline   Reply With Quote
Old 01-11-2012, 01:25 AM   PM User | #9
cub
New Coder

 
Join Date: Jan 2012
Posts: 10
Thanks: 3
Thanked 0 Times in 0 Posts
cub is an unknown quantity at this point
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
cub is offline   Reply With Quote
Old 01-11-2012, 03:56 AM   PM User | #10
mlseim
Master Coder

 
mlseim's Avatar
 
Join Date: Jun 2003
Location: Cottage Grove, Minnesota
Posts: 9,042
Thanks: 8
Thanked 1,029 Times in 1,020 Posts
mlseim has a spectacular aura aboutmlseim has a spectacular aura aboutmlseim has a spectacular aura about
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.
mlseim is offline   Reply With Quote
Reply

Bookmarks

Tags
html, javascript, php

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 11:36 AM.


Advertisement
Log in to turn off these ads.