1

I've built a small widget for my website
It has a couple of inputs, and a <textarea> among others.
Whenever someone inputs to the textarea it adds a tab at the begining
and changes every ' to \'
After a couple of times I save the same input,
I just get sentences that were

It's nice

to

It\\\\'s nice

the code for the Textrea:

         <textarea rows="5" cols="40" id="cat_<?php echo $i ?>_text" name="cat_<?php echo $i ?>_text">
        <?php echo $text ?>
        </textarea>

Any ideas?

1

Try stripslashes to remove the backslash.

echo stripslashes( $text );

This is going to replace one slash per slashes group only though, you should first reset all the contents that have multiple slashes.

I guess the tab at the beginning is due to the fact that you jump a line before echoing the text. Try this instead :

<textarea rows="5" cols="40" id="cat_<?php echo $i ?>_text" name="cat_<?php echo $i ?>_text"><?php echo stripslashes( $text ); ?></textarea>
|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.