Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
quotes and apostrophes in form
Old 06-18-2008, 01:10 AM quotes and apostrophes in form
Skilled Talker

Posts: 69
Trades: 0
Hello all,

I am having the problem of my form erroring out when quotes and apostrophes are entered into the form field or text area.

What do you think is the best wat to rectify?

form field:
<textarea name="Comments" rows="8" cols="50"><?php echo stripslashes(ereg_replace('"','"',$webinfo31)); ?></textarea>

on confirmation page:
{$webinfo31=htmlspecialchars($_POST['Comments']);}

Will this work or is there a better way?

Thanks,
Matt
__________________
Matt
webmaster of
Please login or register to view this content. Registration is FREE
- Online wedding planning
weddingm is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 06-18-2008, 05:15 PM Re: quotes and apostrophes in form
Skilled Talker

Posts: 71
Trades: 0
You're stripping slashes, you want to addslashes.

<?php echo addslashes($webinfo31); ?>

{$webinfo31=stripslashes($_POST['Comments']);}

Try this.
CrazeDizzleD is offline
Reply With Quote
View Public Profile
 
Old 06-19-2008, 12:28 AM Re: quotes and apostrophes in form
Skilled Talker

Posts: 69
Trades: 0
I have found the php code htmlspecialchars. I really like this as it does what I want on Guestbook comments. However, in other forms, I recommend using the <br> to go to the next line. The problem is that htmlspecialchars put's the data into the datase so that when the data is pulled onto a web page, the data shows the <br> and doesn't break right.

Geez, I have been doing alot of reading on this and you have to worry so much about hacker codes. I want something that works but will not make my database prone to hacking.

Matt
__________________
Matt
webmaster of
Please login or register to view this content. Registration is FREE
- Online wedding planning
weddingm is offline
Reply With Quote
View Public Profile
 
Old 06-19-2008, 12:42 AM Re: quotes and apostrophes in form
Skilled Talker

Posts: 71
Trades: 0
Use mysql_escape_string () before you insert it into the database, then stripslashes () when you get it back out.
CrazeDizzleD is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to quotes and apostrophes in form
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting 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 Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.26143 seconds with 12 queries