 |
 |
PHP Text Input Help
|
 |
|
 |
|
Dedicated MacNNer
Join Date: May 2002
Location: Brooklyn, NY
Status:
Offline
|
|
Hi,
I've written a nice small message board for some friends in PHP and MySQL. I was wondering however how to make the message box behave more like the one on this forum. For instance, if you type a return, it sends through a [br], or if you type a quote, it sends it as a quote. At the moment, it won't even post if there's a quote in the message. I remember seeing something like to_HTTP_STRING() or something like that. Any advice?
Thanks!
gabe
|
|
|
| |
|
|
|
 |
|
 |
|
Occasionally Useful
Join Date: Jun 2001
Location: Liverpool, UK
Status:
Offline
|
|
i'd suggest downloading phpBB and looking at the code. it's bound to be pretty much the same method as vB uses. i've learnt a few things that way.
|
|
"Have sharp knives. Be creative. Cook to music" ~ maxelson
|
| |
|
|
|
 |
|
 |
|
Junior Member
Join Date: Feb 2002
Location: paris
Status:
Offline
|
|
You definitely should do:
$text = addslashes($text);
before you try to insert the text into the database. This adds slashes before all quotes.
If you don't, SQL will choke on the quote charaters. Or worse, someone could attack your database with a cleverly devised message.
Before you display the message you just have to do:
$text = stripslashes($text);
after you get it from the database.
|
|
|
| |
|
|
|
 |
|
 |
|
Mac Elite
Join Date: Apr 2001
Location: Frickersville
Status:
Offline
|
|
I know this isn't what you want to hear, but why not just use phpBB? It's free and fits into your PHP/MySQL combo requirements. It's powerful and did I mention free?
Unless you're just doing it for the fun of it... in which case, go nuts!
|
|
|
| |
|
|
|
 |
|
 |
|
Grizzled Veteran
Join Date: Jun 2001
Location: Melbourne, Australia
Status:
Offline
|
|
Originally posted by Zimwy:
Hi,
I've written a nice small message board for some friends in PHP and MySQL. I was wondering however how to make the message box behave more like the one on this forum. For instance, if you type a return, it sends through a [br], or if you type a quote, it sends it as a quote. At the moment, it won't even post if there's a quote in the message. I remember seeing something like to_HTTP_STRING() or something like that. Any advice?
Thanks!
gabe
$text = nl2br(htmlentities(stripslashes($text), ENT_QUOTES));
|
|
Computer thez nohhh...
|
| |
|
|
|
 |
 |
|
 |
|
|
|
|
|

|
|
 |
Forum Rules
|
 |
 |
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
 |
 |
 |
 |
|
 |
|