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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

strip_slashes

Status
Not open for further replies.

sjaakdelul

IS-IT--Management
Sep 19, 2002
43
NL
I've this form:


<html>
<head>
</head>
<body>
<?
switch ($target)
{
case &quot;&quot;:
stap3();
break;
case &quot;stap31&quot;:
stap31();
break;
case &quot;stap310&quot;:
stap310();
break;
case &quot;stap4&quot;:
stap4();
break;
}

function stap3()
{
?>
<form name=&quot;form1&quot; method=&quot;post&quot; action=&quot;test.php?target=stap31&quot;>
<input name=&quot;diagnose&quot; type=&quot;text&quot; id=&quot;diagnose&quot; size=&quot;15&quot;>
<input type=&quot;submit&quot; name=&quot;Submit&quot; value=&quot;ga verder-->&quot;>
</form>
<?
}

function stap31 ()
{
?>
<form name=&quot;form1&quot; method=&quot;post&quot; action=&quot;test.php?target=stap310&quot;>
<? echo &quot;<input type=hidden name=diagnose value='&quot; . htmlspecialchars($_POST['diagnose']) . &quot;'>&quot;; ?>
<input name=&quot;naam2&quot; type=&quot;text&quot; id=&quot;naam2&quot; size=&quot;15&quot;>
<input type=&quot;submit&quot; name=&quot;Submit&quot; value=&quot;ga verder-->&quot;>
</form>
<?
}

function stap310 ()
{
?>
<form name=&quot;form1&quot; method=&quot;post&quot; action=&quot;test.php?target=stap4&quot;>
<? echo &quot;<input type=hidden name=diagnose value='&quot; . htmlspecialchars($_POST['diagnose']) . &quot;'>&quot;; ?>
<? echo &quot;<input type=hidden name=naam2 value='&quot; . htmlspecialchars($_POST['naam2']) . &quot;'>&quot;; ?>
<input name=&quot;naam3&quot; type=&quot;text&quot; id=&quot;naam3&quot; size=&quot;15&quot;>
<input type=&quot;submit&quot; name=&quot;Submit&quot; value=&quot;ga verder-->&quot;>
</form>
<?
}

function stap4 ()
{
echo $_POST[diagnose];
echo&quot;\n&quot;;
echo $_POST[naam2];
echo&quot;\n&quot;;

}
?>

</body>
</html>


It's quit simple.
The problem is that PHP turns the input

&quot;hey&quot; into \\\\\\\&quot;hey\\\\\\\&quot;

I've heard to use strip-slashes, but I don't understand it.
magic_quotes_gpc is set 'on' in the ini file.

Now, I am using htmlspecialchars, but for form to form data tossing with magic quotes on htmlspecialchars fails, because it will then translate the ampersands into &s;

I've tried this code:

$apos = &quot;'&quot;;
$quot = &quot;&quot;&quot;;

if($products){
while (list ($key, $val) = each($products)) {
$products[$key] = str_replace(&quot;'&quot;,$apos,stripslashes($val));
$products[$key] = str_replace('&quot;',$quot,stripslashes($val));
}
reset($products);
}

This is not working for me. But I think I've used it at the wrong way ...

Does someone knows how to use strip-slashes at the good way??

Thx!
 
OK, &quot;hey&quot; becomes \\\\\\\&quot;hey\\\\\\\&quot;
but, 'hey becomes
So, when the user use ' in the inputfiled, the data gets lost!

Is the any solution and answer for this problem?
 
This code works:


$diagnose = $_POST['diagnose'];
$_POST['diagnose'] = ereg_replace(&quot;\&quot;&quot;,&quot;&quot;&quot;,stripslashes($diagnose));


Now, I want to add these one:


$_POST['diagnose'] = ereg_replace(&quot;\'&quot;,&quot;&acute;&quot;,stripslashes($diagnose))


How can i use these codes together?
 
swap the order and you should be able to use the two together no? First turn all the \' to ', then turn all the remaining \ to nothing...

-Rob
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top