English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

I have a form that contains the following code snippet:

*******

$encodedRecipeName = urlencode($recipeName);
echo " $encodedRecipeName . "\'>" . $recipeName;
**********
On the page that I want to display this information, I have the following code:

**********
$recipeName =$_POST['recipeName'];
$recipeName= trim($recipeName);
if (!$recipeName)
{
echo 'You have not entered search details. Please go back and try again.';
exit;
}

if (!get_magic_quotes_gpc())
{
$recipeName = addslashes($recipeName);
}
echo $recipeName;

**********

If $recipeName is "Grilled Chicken Sandwich", the result of the above code is:

\\\'Grilled+Chicken+Salad\\\'

How do I get rid of all the slashes, quotation marks, and plus signs?

2006-11-09 04:55:15 · 2 answers · asked by Anonymous in Computers & Internet Programming & Design

2 answers

Well, there's a simple rule: if you use encoding on the sending end, you must decode on the receiving end. So instead of

$recipeName = $_POST['recipeName'];

you should have

$recipeName = urldecode ($_POST['recipeName']);

2006-11-10 04:24:08 · answer #1 · answered by NC 7 · 0 0

You have single quotes surrounding the VALUE clause in the original form

2006-11-10 02:33:35 · answer #2 · answered by danieltoomeydanieltoomey 2 · 0 0

fedest.com, questions and answers