Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > PHP Text Input Help

PHP Text Input Help
Thread Tools
Dedicated MacNNer
Join Date: May 2002
Location: Brooklyn, NY
Status: Offline
Reply With Quote
Sep 27, 2003, 11:36 AM
 
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
Reply With Quote
Sep 27, 2003, 12:36 PM
 
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
Reply With Quote
Sep 27, 2003, 12:52 PM
 
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
Reply With Quote
Sep 28, 2003, 10:06 PM
 
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!

Mystical, magical, amazing! | Part 2 | The spread of Christianity is our goal. -Railroader
     
Grizzled Veteran
Join Date: Jun 2001
Location: Melbourne, Australia
Status: Offline
Reply With Quote
Sep 29, 2003, 08:53 AM
 
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...
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 07:12 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2