How do i put this code on my web site?
November 12, 2005 5:59 AM   Subscribe

Can anyone guide me in creating a page just like this one?

What i'd like to do is exactly the same as that page. Have visitors add phrases to a pool, and have the java script display the phrases randomly on a specified page. My coding knowledge is limited, especially in php, so any tutorials or similar scripts would be helpful. I've already tried to contact the owner of the site for assistance, but they never replied.
posted by deadmouse to Computers & Internet (4 answers total)
 
This would be best done with a database (mysql) in conjunction with PHP. But that may involve more complexity than you want.

If you're looking for a flat-file solution, see this documement about pulling random lines from a file.

This explains how to write to the flat file.

You will also want to learn file locking, so that two people don't try to write data to the file at once (which might corrupt the file).
posted by grumblebee at 7:02 AM on November 12, 2005


Also, make sure you sanitise the phrases in some way before they're output back onto your site's pages. Otherwise someone could come along and stick in whatever HTML or JavaScript that they wanted, and have it display on your site as if it was part of the legitimate HTML.

A crude but easy way would be to use something like htmlentities to convert all the <'s and >'s into harmless HTML entities.
posted by chrismear at 7:17 AM on November 12, 2005


Whoops, I actually meant htmlspecialchars, which only translates the dangerous characters (&, <, >).
posted by chrismear at 7:21 AM on November 12, 2005


thanks, good stuff! i will be looking into implimenting this in the very near future.
posted by deadmouse at 1:07 PM on November 12, 2005


« Older sore buttocks while sitting   |   Looking for Failed Rescue Video Newer »
This thread is closed to new comments.