Error: POST Method Not Allowed

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
sunkara
Forum Newbie
Posts: 3
Joined: Thu Jan 09, 2003 1:10 pm

Error: POST Method Not Allowed

Post by sunkara »

Hi..I am new to php. I wrote a simple program with forms in it. I am encountering this error message whenever i try to run any php program with forms....Method Not Allowed
The requested method POST is not allowed for the URL /calculate.php.


Could anybody please help me with this?

This is my calculate_fom.html which calls calculate.php

Code: Select all

<html>
<head>
<title>Calculation Form</title>
</head>

<body>
<form method="post" action="calculate.php">
  <p>Value 1 : 
    <input type="text" name="val1" size="10">
</p>
  <p>Value 1 : 
    <input type="text" name="val2" size="10">
  </p>
  <p>Calculation:<br>
    <input type="radio" name="calc" value="add">
    add <br>
	  <input type="radio" name="calc" value="subtract">
    subtract<br>
	  <input type="radio" name="calc" value="multiply">
    multiply<br>
	  <input type="radio" name="calc" value="divide">
    divide<br></p>
  <p>
    <input name="submit" type="submit" VALUE="Calculate">
  </p>
</form>
</body>
</html>
This is calculate.php

Code: Select all

<?php
if (($_POST&#1111;'val1']=="")||($_POST&#1111;'val2']=="")||($_POST&#1111;'calc']==""))&#123;
   header("Location:http://localhost/calculate_form.html");
   exit;
&#125;

if ($_POST&#1111;'calc']=="add")&#123;
    $result = $_POST&#1111;'val1'] + $_POST&#1111;'val2'];
&#125;
else if ($_POST&#1111;'calc']=="subtract")&#123;
    $result = $_POST&#1111;'val1'] - $_POST&#1111;'val2'];
&#125;
else if ($_POST&#1111;'calc']=="multiply")&#123;
    $result = $_POST&#1111;'val1'] * $_POST&#1111;'val2'];
&#125;
else if ($_POST&#1111;'calc']=="divide")&#123;
    $result = $_POST&#1111;'val1'] / $_POST&#1111;'val2'];
&#125;

?>


<html>
<head>
<title>Calculation result</title>
</head>

<body>
<p>The result of the calculation is : <?php echo "$result"; ?></p>
</body>
</html>
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

without posting data the php-scripts do work? e.g. just calling the script

Code: Select all

&lt;?php phpinfo(); ?&gt;
outputs something else than just the text?
  • Just the text: Your webserver is not configured to use php and POST is not allowed for static pages (as which the server then treats your document)
  • "I can see the credentials and the configuration": Allowed methods can be restricted. If you're using an apache-server read http://httpd.apache.org/docs/mod/core.html#limit
sunkara
Forum Newbie
Posts: 3
Joined: Thu Jan 09, 2003 1:10 pm

Thank u

Post by sunkara »

Thanx volka...it helped me....ya, i did not configure my php with my webserver correctly.
Post Reply