Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Forms Proccessing

0 views
Skip to first unread message

Honky Tonk Hero

unread,
Feb 8, 2005, 1:15:24 PM2/8/05
to
Hello,

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

Geoff Berrow

unread,
Feb 8, 2005, 1:43:28 PM2/8/05
to
I noticed that Message-ID:
<0l7Od.3164$ZZ....@newssvr23.news.prodigy.net> from Honky Tonk Hero
contained the following:

>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/

Alvaro G. Vicario

unread,
Feb 8, 2005, 2:29:47 PM2/8/05
to
*** 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:

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
--

Kevin

unread,
Feb 8, 2005, 2:58:59 PM2/8/05
to
On Tue, 8 Feb 2005 20:29:47 +0100
"Alvaro G. Vicario" <kAlvaroNO...@terra.es> wrote:

> *** 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";

Honky Tonk Hero

unread,
Feb 10, 2005, 1:48:27 AM2/10/05
to
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?

-- 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

Geoff Berrow

unread,
Feb 10, 2005, 3:05:41 AM2/10/05
to
I noticed that Message-ID:
<%sDOd.3718$ZZ....@newssvr23.news.prodigy.net> from Honky Tonk Hero
contained the following:

>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));

Honky Tonk Hero

unread,
Feb 10, 2005, 11:21:33 AM2/10/05
to
Thanks for the help Geoff!

I appreciate it.

James

0 new messages