Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

strange behaviour, formdata is altered.

Status
Not open for further replies.

lumberjakel

Programmer
Oct 27, 2001
29
NL
Look at this script. First time you use it it show a textarea. When you type something (& submit) it will show how the data will be available for your script.

When you try to enter a ", php changes it to \", for example, he said: "hello world"! will become
he said: \"hello world\"!.

The problem is how PHP auto-decodes the query, because
Code:
echo urldecode($REQUEST_URI);
will show normal quotes.

How can I solve this?

Code:
<?
if (empty($textfield))
{
?>
<form name=&quot;form1&quot; method=&quot;get&quot; action=&quot;&quot;>
  <textarea name=&quot;textfield&quot;></textarea>
  <br>
  <input type=&quot;submit&quot; value=&quot;Submit&quot;>
</form>
<?
}
else
{
  echo $textfield.&quot;<br>&quot;;
  echo urldecode($REQUEST_URI);
}
?>
 
thanx, but I was looking for a function to tell PHP not to add the slashes in the first place...
 
becaus I want to know how to upgrade my old scripts without adding stripslashes to much lines. If there was a way to tell PHP not to add tehm in the first place...
 
I made a script which does the trick:
Code:
function reparse()
{
  $arr=explode(&quot;&&quot;, getenv(&quot;QUERY_STRING&quot;));
  foreach ($arr as $var_val)
  {
    list ($var, $val)=explode(&quot;=&quot;, $var_val);
    $GLOBALS[$var]=urldecode($val);
  }
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top