Jump to content

Newbie Needs Help! SOS!!!


enrique

Recommended Posts

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>

Link to comment
https://forums.phpfreaks.com/topic/90360-newbie-needs-help-sos/
Share on other sites

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?

Link to comment
https://forums.phpfreaks.com/topic/90360-newbie-needs-help-sos/#findComment-463279
Share on other sites

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?

Link to comment
https://forums.phpfreaks.com/topic/90360-newbie-needs-help-sos/#findComment-463287
Share on other sites

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?

Link to comment
https://forums.phpfreaks.com/topic/90360-newbie-needs-help-sos/#findComment-463294
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/90360-newbie-needs-help-sos/#findComment-463300
Share on other sites

Archived

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

×
×
  • Create New...

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.