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
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
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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.