PHP Text Processing

Associate
Joined
3 Oct 2006
Posts
2,304
Location
London
Hi There,

Does anyone have any links to tutorials or guides which show you some good was to process text that has been entered into a text area in a web form.

Many thanks,

Jon
 
Aye, I guess. Sorry. Basically I'm making a comments system, and I wan't to make it easy / safe to store in a database / edit, without it screwing up and line spacing going wrong or odd characters displaying etc.

Specifically how to deal with new lines and how to deal with unwebsafe characters.
 
I get you.

Firstly, you need to sanitise all your user input before it goes into the database. See robmiller's security guide:
http://php.robm.me.uk/#toc-SQLInjection

Once it's actually in the database and you want to display it, you need to make sure that it won't mess up the site's actual markup. For example, a user could put something like </body></html> in the text. You can use htmlspecialchars() to avoid this problem.

You should really read Rob's guide though as it's far more thorough :)
 
Back
Top Bottom