Page 1 of 1

Dynamic change of contens

Posted: Mon Jul 11, 2005 7:54 am
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 ?

Posted: Mon Jul 11, 2005 8:41 am
by thegreatone2176
record the ip of each visit and how many times they have visited your site and display the banner based on that

Posted: Mon Jul 11, 2005 8:50 am
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.

Posted: Mon Jul 11, 2005 11:25 am
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 ;) :)

Posted: Mon Jul 11, 2005 11:30 am
by gustaf67
WoW !!! Talk about feedback !!

Well, what if the user is coming from proxy then the ip thing would work.... would it ?

Posted: Mon Jul 11, 2005 11:33 am
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 ;) :)

Posted: Mon Jul 11, 2005 11:49 am
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.

Posted: Mon Jul 11, 2005 12:07 pm
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.