Jump to content

Prevent Variable Escaping


xstevey_bx

Recommended Posts

I am trying to create a simple code generator where you enter details in a form and when you click submit the values you entered are writen into the code which changes it to your needs.

The problem is that I have a text box which you are able to write some html. However, whenever I call it in the code any of the [b]"[/b] or [b]'[/b]s in the code are changed to [b]\"[/b] or [b]..'[/b]

[code]
<?php
$friendid = $_POST['friends_id'];
$title = $_POST['myspace_title'];
$sideimage = $_POST['url_to_image'];
$aboutme = $_POST['about_me_text'];
$codetext = htmlentities($aboutme);

echo "<textarea rows='5' name='S1' cols='62'>". $codetext ." </textarea>"; ?>
[/code]

That is a simple version of the code im using with all the variables.

The link to the page is http://www.steveyb.com/pagefiles/portfolio/layouts/pages/image_side_corporate/

Is there anyway to have any html code typed into "about me" forum box, show up in the PHP without it being escaped?

thanks
Link to comment
Share on other sites

looms like you have magic quotes enabled whcih is why your quotes are being escaped. To stop it from the doing that you should turn magic quotes off by either edting the php.ini if your host allows it or you can do it via the htaccess file.

If you cannot edit the php.ini or use .htaccess files then you can use stripslashes function, which will remove the escape character from the quotes.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.