![]() |
|
#1
|
|||
|
|||
GuestbookHi,
I'm working on a guestbook for a website, and I'm almost finished. I'm dedicated to making this the best guestbook ever, and so far, I have added tons of features. Users can edit their own entries, customize the color of their entry, add emoticons (and maybe an avatar), and of course all the basic features of any guestbook. Now, I face one problem...how do I prevent users from submitting an entry? I know that I have to track IPs and set cookies in the user's browser, but I have no clue how to do this. Could anyone help me? Thanks! __________________
You're not supposed to be looking at this. |
|||
|
#2
|
||||
|
||||
Setting Cookies with PHPI am sure you meant "how do I prevent users from submitting multiple entries?"...
I will have to assume you are using a database table or 2 to manage this Guestbook since you did not specify if this is true. If yes, just add a new column for the IP address (in the table where you store the posts). I am certain this table already includes a timestamp column - so you can use that. What you want the script to do when someone posts is to:
Setting a cookie with PHP Let's assume a few things first: Guestbook script is named BestGB. URL / folder to the script is http://www.example.net/gb/ PHP Code:
Verify a cookie with PHP To verify if a cookie contains valid data or if it was even set (you can do either), code like this will help. PHP Code:
If you find yourself having problems setting a cookie midway in your script, put the following line right at the top of your script; I am not sure if it would work but let me know... PHP Code:
The IP is straight forward using the $_SERVER['REMOTE_ADDR'] to put into the db and to verify (together with the timestamp) later on... Off topic: If you allow Guestbook entries to be edited by your readers, you will be creating a monster. Better to allow edits only within a span of 1 hour from the time of the initial post, for example. __________________
J de Silva Learning Journal | GIDForums™ | GIDNetwork™ | GIDWebhosts™ | GIDSearch™ |
|
#3
|
||||
|
||||
|
This really is a helpful forum
![]() |
|
#4
|
|||
|
|||
|
WOW! Thank you very much, JdS. I will try it as soon as I get home.
I think you should post another copy of that post in the Code database. (Oops...I did mean to write "multiple entries". Of course I want the viewers to submit entries. )__________________
You're not supposed to be looking at this. |
|
#5
|
||||
|
||||
|
Quote:
It is my hope that the popular Search Engines will take care of it for us... incase nothing appears next month in the SERP to this thread then I will make some changes like you suggest (no point confusing the bots by having duplicate pages until then). __________________
J de Silva Learning Journal | GIDForums™ | GIDNetwork™ | GIDWebhosts™ | GIDSearch™ |
Recent GIDBlog
Accepted for Ph.D. program by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Guestbook error | BobbyDouglas | Web Design Forum | 1 | 16-Oct-2003 23:17 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The