Raymondo Posted December 18, 2005 Share Posted December 18, 2005 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 Quote Link to comment Share on other sites More sharing options...
ProFire Posted December 19, 2005 Share Posted December 19, 2005 [!--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. Quote Link to comment Share on other sites More sharing options...
Raymondo Posted December 28, 2005 Author Share Posted December 28, 2005 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.