Dynamic change of contens

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
gustaf67
Forum Newbie
Posts: 2
Joined: Mon Jul 11, 2005 7:37 am

Dynamic change of contens

Post by gustaf67 »

Newbee here
I wounder if it possibel to change text in tabel.
If a user arrives to my site I want to display "hello friend!"
second time I want to dispay "A friend in need is a friend in deed"
or something.
How do I do this ?
thegreatone2176
Forum Contributor
Posts: 102
Joined: Sun Jul 11, 2004 1:27 pm

Post by thegreatone2176 »

record the ip of each visit and how many times they have visited your site and display the banner based on that
Dale
Forum Contributor
Posts: 466
Joined: Fri Jun 21, 2002 5:57 pm
Location: Atherstone, Warks

Post by Dale »

Or if it is the persons first visit, set a cookie for your site, then get your site to do a check to find that cookie, if it finds that cookie then get it to show the second message. If not then it will show message one.
User avatar
IceMetalPunk
Forum Commoner
Posts: 71
Joined: Thu Jul 07, 2005 11:45 am

Post by IceMetalPunk »

Dale, what if the user clears his cookies? Then every time he clears his cookies, he will get the same 1st visit message. The best way is to write a PHP file that writes a text file on the server. In this file have something like this:

Code: Select all

127.0.0.1-0
157.0.0.1-1
147.0.0.1-0
197.0.0.1-1
Of course, the IPs would be real IPs of the people that have logged in. When someone registers, add their IP to the list with a 0 after it. When they visit the site, read the text file. Explode it at every line break (\n for linux, \r\n (the are is supposed to be the lower-case letter)), then split those at the -. Go through the array and find the IP that matches the user's. Then go to the index 1 of that array index, and get the number. If it's 0, echo the 1st-time visitor message and change it to 1. Otherwise, echo the normal message.

-IMP ;) :)
gustaf67
Forum Newbie
Posts: 2
Joined: Mon Jul 11, 2005 7:37 am

Post by gustaf67 »

WoW !!! Talk about feedback !!

Well, what if the user is coming from proxy then the ip thing would work.... would it ?
User avatar
IceMetalPunk
Forum Commoner
Posts: 71
Joined: Thu Jul 07, 2005 11:45 am

Post by IceMetalPunk »

That I'm not sure about... I think it might, though.... after all, most routers have proxies for protection, yet whatismyip.com uses PHP to get the correct IP address, and that works.

-IMP ;) :)
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

Well, if a user decides not to accept/clean his cookies that his choice...

But, a user usually can't choose the IP he will be assigned by his ISP. Or which proxy he will be using...

Therefor i think the $_COOKIES implementation is more reliable.
Roja
Tutorials Group
Posts: 2692
Joined: Sun Jan 04, 2004 10:30 pm

Post by Roja »

IceMetalPunk wrote:That I'm not sure about... I think it might, though.... after all, most routers have proxies for protection, yet whatismyip.com uses PHP to get the correct IP address, and that works.

-IMP ;) :)
Whatismyip is often hailed as some miraculous thing.. its over-rated. It does *not* see my home computer's ip address, which goes through a gateway machine. It does *not* see my work computer ip address, which goes through a proxy.

It only sees what the proxies LET it see, and if the user is using a gateway, or coming from a work address, it wont get the right IP.

I've said it before, and I'll say it hundreds of times again.. IP != user. Never has, never will. Its completely unreliable.

Not to mention, a TEXT file?? google or aol hits and that text file will grow to megs of text, and be unparse-able in any reasonable amount of time. Thats what databases are built for.
Post Reply