enrique Posted February 10, 2008 Share Posted February 10, 2008 Hi there, I am all new to this arena.... I am using php-5.2.5, apache 2.0.63, MySQL 4.1. When I click on submit on the following code, I get an error saying "Forbidden You don't have permission to access /< on this server." <html> <head></head> <body> <?php // if the "submit" variable does not exist // form has not been submitted if(!$_POST['submit']) { ?> <form method="post" action = "<?php echo $_SERVER['PHP_SELF'] ?>" > Enter a number of rows: <input name="rows" type="text" size="4"> and columns <input name="columns" type="text" size="4"> <input type="submit" name="submit" value="Draw Table"> </form> <?php } else { ?> <table border="1" cellspacing="5" cellpadding="0"> <?php //set variable from form input $rows = $_POST['rows']; $columns=$_POST['columns']; //loop to create rows for ($r=1; $r <= $rows; $r++) { echo "<tr>" //loop to create columns for ($c = 1; $c <= $columns; $c++) { echo "<td> </td>\n"; } echo "<tr>\n"; } ?> </table> <?php } ?> </body> </html> Quote Link to comment Share on other sites More sharing options...
trq Posted February 10, 2008 Share Posted February 10, 2008 What permissions are set on the file? Quote Link to comment Share on other sites More sharing options...
enrique Posted February 10, 2008 Author Share Posted February 10, 2008 I myself, system and administrator have full control... user's have read and read execute permissions only.. I dont know whether this would help... the result URL says: http://localhost/<?php%20echo%20$_SERVER['PHP_SELF']%20?> What permissions are set on the file? Quote Link to comment Share on other sites More sharing options...
trq Posted February 10, 2008 Share Posted February 10, 2008 Firstly, nothing like the above should show up in your url because you are using the post method, not get. Secondly, there simply is no need for $_SERVER['PHP_SELF'] as your form action. By default, forms post back to themselves. eg; <form method="post"> is all you need. Does a test php page work? Put this in a file and browse to it via http://localhost/file.php. <?php phpinfo(); ?> What do you see? Quote Link to comment Share on other sites More sharing options...
enrique Posted February 10, 2008 Author Share Posted February 10, 2008 phpinfo works fine.... giving me well structured, purple colored page of all the functions... How should I restructure my code as you suggested... But I must mention whenever I use $_SERVER['PHP_SELF'] I get the above error... Is that a known issue...?? Firstly, nothing like the above should show up in your url because you are using the post method, not get. Secondly, there simply is no need for $_SERVER['PHP_SELF'] as your form action. By default, forms post back to themselves. eg; <form method="post"> is all you need. Does a test php page work? Put this in a file and browse to it via http://localhost/file.php. <?php phpinfo(); ?> What do you see? Quote Link to comment Share on other sites More sharing options...
enrique Posted February 10, 2008 Author Share Posted February 10, 2008 even if I use <?=_SERVER['PHP_SELF']?> , this doesn't work either.... Quote Link to comment Share on other sites More sharing options...
trq Posted February 10, 2008 Share Posted February 10, 2008 As i said, your form simply needs to use... <form method="post"> It doesn't require a action. Having said that though, what you posted originally should work. <form method="post" action="<?php echo $_SERVER['PHP_SELF'] ?>"> I'm not sure you can have spaces around the = though. 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.