quotes in textarea

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
and new problem... buit this time I haven't found solution in some

problem: I would like to allow <a href="link"> tag, but I'm having
problems in hidden field when checking message:


(STAGE 1 = typing <a href="link">message</a>)
<form method="post">
<textarea name="message"></textarea>

(STAGE 2 = checking message, my wish)
$message = $_POST['message']
<p>Is following correct?<p>
<p>typing <a href="link">message</a></p>
<form method="post">
<input type="hidden" name="message" value="message">

(STAGE 2 = checking message, my problem)  <----!
$message = $_POST['message']
<p>Is following correct?<p>
<p>typing <a href="link">message</a></p>
<form method="post">
<input type="hidden" name="message" value="typing <a
href="link">message</a>">  <----!

there it breaks... my $message became
"typing <a href="
insead of
typing <a href="link">message</a>

what to do?
one soulution came right now to my mind... but still have some
to create copy of $message and to place that copy to hidden holder and
later, just before inserting it to mysql db, to convert it back.... and
what will happen in mysqldb with "?

preg_replace " with ******...? hm, how to find "\""?
maybe preg_replace('/\?\"/', '******', $tekst) ?


Re: quotes in textarea

Quoted text here. Click to load it

use addslashes() on the data in stage 2. ie
$message = addslashes($_POST['message']);
that should do the trick.

Re: quotes in textarea

I think the problem is that quotes are only allowed to surround values
in html tags
if you want a quote anywhere else, use &quot;... same goes with <, >, &

IE  <input type="hidden" name="message"
value="typing &lt;a href=&quot;link&quot;&gt;message&lt;/a&gt;">

use htmlspecialchars()

if that's not your immediate problem, it will be your next one.

Site Timeline