I have a premade for that is having probelms dealing with aposterphies
and forward slahes. Is there a way to edit the code so it does not alter
aposterphies and forward slahes?
Example:
If I enter ' the form displays it as /'
If I enter / the for displays it as //
I'm a very very new comer to PHP, so please be gental.
Thanks in advance for your help,
HTH Brand
>If I enter ' the form displays it as /'
>If I enter / the for displays it as //
>
>I'm a very very new comer to PHP, so please be gental.
Instead of
echo $_POST['name_of_field'];
do
echo stripslashes($_POST['name_of_field']);
--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
It's a pretty stupid "feature" that PHP has. It can either be enabled or
disabled, in your server it seems to be enabled. Check this:
http://es2.php.net/manual/en/security.magicquotes.php
You can either disable it (if it's possible) or use code to detect it and
act accordingly.
--
-+ Álvaro G. Vicario - Burgos, Spain
+- http://www.demogracia.com (la web de humor barnizada para la intemperie)
++ Manda tus dudas al grupo, no a mi buzón
-+ Send your questions to the group, not to my mailbox
--
> *** Honky Tonk Hero escribió/wrote (Tue, 08 Feb 2005 18:15:24
> GMT):
> > I have a premade for that is having probelms dealing with
> > aposterphies and forward slahes. Is there a way to edit the
> > code so it does not alter aposterphies and forward slahes?
> > Example:
> > If I enter ' the form displays it as /'
> > If I enter / the for displays it as //
>
> It's a pretty stupid "feature" that PHP has. It can either be
> enabled or disabled, in your server it seems to be enabled.
> Check this:
Yeah, totally useless.
[...]
> You can either disable it (if it's possible) or use code to
> detect it and act accordingly.
Yes, and it's better not to depend on the server. Here's a way:
$r = get_magic_quotes_gpc();
function strip_r($v) {
$v = is_array($v) ?
array_map('strip_r',$v) : stripslashes($v);
return $v;
}
if ($r) {
$_POST = array_map('strip_r', $_POST);
$_GET = array_map('strip_r', $_GET);
$_COOKIE = array_map('strip_r', $_COOKIE);
}
And for runtime magic quotes,
$i = get_magic_quotes_runtime();
$r = set_magic_quotes_runtime(0);
if($i)
if (!$r)
print "Can't set. Can't help.\n";
Now for a very newb question... (I mean very newb. New as in "This is
the first time I've messed with PHP".)
Based on the code below, how and were would I set up the code to fix the
Magic Quotes?
-- BEGINE CODE --
$blanks = 0;
foreach($_POST as $key => $value) {
if ($value)
{
$url .= "&" . $key . "=" . urlencode($value);
}
else
{
if (!(($key == "Address2") || ($key == "OtherNetEquip") || ($key ==
"PVR") || ($key == "PremChannel") || ($key == "OtherAV") || ($key ==
"Mailinglist") || ($key == "Comments")))
$blanks++;
}
}
// echo "url:$url<br>\n";
// $url = urlencode(urlencode($url));
// echo "urlencoded:$url<br>\n";
if ($blanks)
echo '<meta http-equiv="refresh" content="'.$delay.';url='.$url.'">';
else
{
-- END CODE --
Thank you very much for your help.
Warren
HTH Brand
>Hey thanks for the great support fellas!
>
>Now for a very newb question... (I mean very newb. New as in "This is
>the first time I've messed with PHP".)
>Based on the code below, how and were would I set up the code to fix the
>Magic Quotes?
<snip>
> $url .= "&" . $key . "=" . urlencode($value);
$url .= "&" . $key . "=" . stripslashes(urlencode($value));
I appreciate it.
James