Jump to content

Archived

This topic is now archived and is closed to further replies.

Raymondo

Permission problem for newbie

Recommended Posts

Hi,

I'm an absolute beginner trying to teach myself Apache, PHP and MySql. I have a PC running Windows XP and have set up a local server. The installation went reasonably well though it was rather daunting for a complete beginner. Anyway, I got things working and set off with PHP book in hand. The first few scripts worked without a problem but then came a script that was refused access with the following error message:

 

--------------

Forbidden

 

You don't have permission to access /phpStuff/< on this server.

 

Apache/2.0.55 (Win32) PHP/5.1.1 Server at localhost Port 80

--------------

 

phpStuff is the directory where I create my scripts and run them. It lives in a directory called

 

D:\MyServer\Apache Group\Apache2\htdocs

 

The script I'm running is:

 

<?php

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 {

$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 zero';

}

}

?>

 

When first loaded, the if part is executed no problem. When I submit the form, I get the above message.

 

Any help would be greatly appreciated.

Raymondo

Share this post


Link to post
Share on other sites

[!--quoteo(post=328225:date=Dec 18 2005, 08:48 AM:name=Raymondo)--][div class=\'quotetop\']QUOTE(Raymondo @ Dec 18 2005, 08:48 AM) 328225[/snapback][/div][div class=\'quotemain\'][!--quotec--]

Hi,

I'm an absolute beginner trying to teach myself Apache, PHP and MySql. I have a PC running Windows XP and have set up a local server. The installation went reasonably well though it was rather daunting for a complete beginner. Anyway, I got things working and set off with PHP book in hand. The first few scripts worked without a problem but then came a script that was refused access with the following error message:

 

--------------

Forbidden

 

You don't have permission to access /phpStuff/< on this server.

 

Apache/2.0.55 (Win32) PHP/5.1.1 Server at localhost Port 80

--------------

 

phpStuff is the directory where I create my scripts and run them. It lives in a directory called

 

D:\MyServer\Apache Group\Apache2\htdocs

 

The script I'm running is:

 

<?php

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 {

$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 zero';

}

}

?>

 

When first loaded, the if part is executed no problem. When I submit the form, I get the above message.

 

Any help would be greatly appreciated.

Raymondo

 

I'm not very sure where your problem really lies but you can try some of these solutions out.

 

Instead of a POST method, try GET method.

Instead of "<?=$_SERVER['PHP_SELF']?>" , try to link to the page name instead of having php decide for you.

 

Share this post


Link to post
Share on other sites

Problem turned out to be so basic I'm embarrased. The php.ini file had short tags turned off so <? blah ?> wasn't recognised! Changed to long tags and bingo, all fixed.

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.