Jump to content

apostrophes and urlencode help


dadamssg87

Recommended Posts

i have a textarea in my form. If my validation script detects an error it will send it to the same page with what they had in that textarea encoded in the url. The script detects the $_GET['variable'], decodes it, and stores it as the default in the textarea so they don't have to retype it all again. The problem is the apostrophes add 7 slashes when it gets added back to the textarea. heres the relevant snippets..

 

<?php
function clean_post($variable)
{
$cxn = mysqli_connect($host,$user,$passwd,$dbname) or (mysqli_error($cxn));
   return mysqli_real_escape_string($cxn, strip_tags($variable));
}
$description = clean_post($_POST['description']);
$description = str_replace(array('\r\n', '\r', '\n'), ' ', $description);
$description = urlencode($description);
$base = "http://mywebsite.com/";

        $url = $base."?mm=1&tt=".$description;
$location = "Location:".$url;
die(header($location));

 

and then to output it in the textarea

<?php
$tt = urldecode(strip_tags($_GET['tt']));
<textarea id=location name=location maxlength="140" >
<?php echo $tt; ?>
</textarea>

 

and this is what my url ends up looking like

http://mysite.com/wordpress/?mm=3&tt=what\\\%27s+the+deal%3F

 

and this ends up in my textarea

"what\\\\\\\'s the deal?"

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.