Page 1 of 1

Problems(I think)with superglobals and single quotes.

Posted: Sat Oct 17, 2009 2:32 am
by nomadsoul
Apache 2.2
Fedora 5
Php 5
notepad++
register globals: off

Hi all,
TIA.
I'm not really sure how to ask this question but bear with me while I try to explain.
In my superglobals such as $name_$POST['name'];
'name' is grayed out (i'm using notepad++) and my script does not work, I get a blank browser window on submit. But when I take out the sq's: $name_$POST[name]; name is boldened but I get an Access forbidden! after submit
as in:
You don't have permission blah blah blah. Even with full Chmod 777.
On submit my Url also reads: http://localhost/howto/%3C?=$_SERVER[%27PHP_SELF%27]?%3E

All of my scripts with superglobals are affected. But regular variables and anything else with sq's are unnaffected

here is one of the scripts I'm using. It is a unified form and process script. I hope someone has time to try it on their server and tell me what happens:
From: How to do everything with php and mysql, Vikram Vaswani.

Code: Select all

 
<html>
<head></head>
<body>
<?php
// if the "submit" variable does not exist
// form has not been submitted
// display initial page
 
if (!$_POST['submit'])
{
?>
<form action="<?=$_SERVER[PHP_SELF]?>" method="post">
Enter a number: <input name="number" size="2">
<input type="submit" name="submit" value="Go">
</form>
<?php
}
else
{
// if the "submit" variable exists
// the form has been submitted
// look for and process form data
// display result
$number = $_POST['number'];
if ($number > 0)
{
echo 'You entered a positive number';
}
elseif ($number < 0)
{
echo 'You entered a negative number';
}
else
{
echo 'You entered 0';
}
}
?>
</body>
</html>
 

Re: Problems(I think)with superglobals and single quotes.

Posted: Sat Oct 17, 2009 7:29 am
by jackpf
Do you have short tags turned on?

Re: Problems(I think)with superglobals and single quotes.

Posted: Sat Oct 17, 2009 7:48 am
by nomadsoul
I didn't think about that. I will check. Thanks.
I tried the script on a commercial server and it works fine.
So maybe it is that.

Re: Problems(I think)with superglobals and single quotes.

Posted: Sat Oct 17, 2009 7:57 am
by nomadsoul
phpinfo says:
short_open_tag Off Off

I'm quite befuddled about this.

Re: Problems(I think)with superglobals and single quotes.

Posted: Sat Oct 17, 2009 8:30 am
by jackpf
Well, either turn it on or don't use short tags ;)