Forum Moderators: phranque

Message Too Old, No Replies

"POST" method for PHP scripts

How to resolve POST error?

         

curley

2:57 am on May 4, 2004 (gmt 0)

10+ Year Member



I have a consultant who is trying to help me and he posed the question to my current host and here is a summary:

Consultant:

This is my "FORM" html tag:
form method="post" action="process.php"

This is error:
Method Not Allowed
The requested method POST is not allowed for the URL /~example.com/directory/process.php.

Apache/1.3.27 Server at secure.example.com Port 443

Question is: Please, can you enable "POST" methods for PHP scripts? I think - it's .htaccess file.

I publish simple test:

1. source code:

<form method="post" action="simplest.php">
<input type="submit" value="Submit">
</form>

2. source code of "simplest.php" :

<? echo('POST request working');?>

3. I press button "Submit" and get error:

The requested method POST is not allowed for the URL /~example.com/directory/simplest.php

Host:

I renamed the .htaccess files for that directory and it's parent, though that made not difference unfortunately. Some more Tier II staff will be in today during our normal business hours to have a look at this.

We do not provide script support at this time. If you need help with using htaccess (it is supported by default in all web server configurations) try researching "htaccess" at [httpd.apache.org...]

How can I fix this issue? Thanks for any help!

<Sorry, no personal URLs. See TOS [webmasterworld.com]>

[edited by: tedster at 3:10 am (utc) on May 4, 2004]

jatar_k

3:03 am on May 4, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



try these

<Limit> [httpd.apache.org]
<LimitExcept> [httpd.apache.org]

you can enable POST via <Limit> in htaccess I believe.

jdMorgan

4:42 am on May 4, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I would not expect you to have to enable POST... It would be more usual to have to take steps to disable it.

Make sure that the script and the form page are both in the same domain - For example, don't have the form in http://www.example.com/form and try to post to https://www.example.com/cart
Look for any redirect or script action that might be unintentionally doing this.

If they give you the "We don't support scripts" runaround, then make a simple.html form and ask them to support that. Actually, by pointing you to Apache, they show a level of awareness that's fairly good compared to most...

Jim

curley

12:15 pm on May 4, 2004 (gmt 0)

10+ Year Member



We have already done simplest test and post it to Help desk. We both know 'help desk' answer.

Simple test - here:
[205.214........]

Source code:
<form method="post" action="simplest.php">
<input type="submit" value="Submit">
</form>

Sure, "simplest.html" and "simplest.php" are in the same folder.

In total: at least 2 problems here.
1st problem: method "POST" disabled for secure server.
I mean - for non secure server "POST" method works:
[example.com...]

2nd problem: even for non-secure server "POST" method disabled for CGI scripts. I publish simplest test here:
[example.com...]
source code:
<form method="post" action="test_1.cgi">
<input type="submit" value="Submit">
</form>
Error is the same: "The requested method POST is not allowed".

I need help! :(

Thanks everyone.

curley

1:54 pm on May 4, 2004 (gmt 0)

10+ Year Member



Here's more:

I publish test for "mensedgehhc" site here:

[205.214.......] and get the same error (method POST is not allowed).

curley

5:48 pm on May 4, 2004 (gmt 0)

10+ Year Member



This is from my host...I need help, if anyone has the time....

Hi Joe,

Unfortunately, troubleshooting scripts is outside of the realm of our support and not something our tech support team will have the expertise to assist you with. I would strongly advise working with someone that has specific experience in this area. If there are questions about the configuration of the server, here is complete documentation on what was done on your server:

A new domain, secure.example.com, was created and the SSL certificate for this domain installed.
A vhost.conf file was added to the /home/httpd/vhosts/secure.example.com/conf directory that contains the following:

<IfModule mod_userdir.c>

UserDir /home/httpd/vhosts/*/httpdocs

</IfModule>

What this does is override the default Userdir directive since the vhost.conf file is loaded last.

Whenever a user goes to [secure.example.com...] it gets mapped to /home/httpd/vhosts/domain/httpdocs/. This is what allows you to share the SSL certificate among other domains.

gergoe

5:58 pm on May 4, 2004 (gmt 0)

10+ Year Member


did you ever tried to load the "simplest.php" uri straight into your browser? that might give you the answer at noce

curley

6:01 pm on May 4, 2004 (gmt 0)

10+ Year Member



can you provide more detail on the uri? or the link you suggest? of course replace it with example.com.

thank you.

jdMorgan

6:04 pm on May 4, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



This is a server configuration error. If you need to prove it, then wait until late at night or whenever your server is least active. Put up a "temporarily offline" message on a basic index.html page in your home directory. Then, rename every .htaccess file on your site to some other name to disable them, and try your simple html test form. If POST still does not work, then you need to demand support from your hosting provider. They cannot claim that an html page is a script, because it's not. And they need not support whatever script you are posting to, because it is the POST that is failing to activate the script, so the script isn't even part of this. If you doubt that, then replace your script with a "hello world" script out of some basic book, and tell them you hope they can figure that script out...

A server you can't POST to is rather useless for doing business on the web. So if you get no help, you need to consider switching hosts, with support as a major consideration...

There is simply no way for us here to guess what may be causing your problem, but the most likely cause is that the server is misconfigured in some fundamental way.

Jim

gergoe

6:06 pm on May 4, 2004 (gmt 0)

10+ Year Member


type the fully qualified url (which the form should post the data to) into your browser in the form of http://hostname/some_dir/simplest.php or however your php file is called.

curley

6:39 pm on May 4, 2004 (gmt 0)

10+ Year Member



I sent the entire message to my host saying that experts at my web forum (names not disclosed) mention this and where can they be wrong?

I am just moving to this host and by all accounts, they have been alright with support. But you guys put it in a clear terms.

I am not sure what to do now. I am the one who recommended these guys. This is very stressful.

j

curley

6:55 pm on May 4, 2004 (gmt 0)

10+ Year Member



Here's the reply. The woman is actually very nice and forthright....

___

The VPS includes the default apache configuration -- if anything on it needs to be changed, you are free to make those changes at your own discretion. I'm guessing that the post below assumes that you do not have root access to the server to make any changes, as is often the case. If you would like us to make any changes to the server configuration, we can do so at our $90.00/hr tech support rate along with your guidelines on what you'd like changed. I don't mean to be difficult -- the problem here is that we have no knowledge of the scripts you are trying to run or what the end result should be, which is why we do not provide this type of support. I hope that makes sense. The suggestion you received below on generating a simple 'hello world' script on the server to be sure it works might help point you in the right direction on where to begin troubleshooting your scripts.
___

gergoe

7:00 pm on May 4, 2004 (gmt 0)

10+ Year Member


by the way, does it works if you use get instead of the posting?

jatar_k

7:04 pm on May 4, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



- try a phpinfo [ca.php.net] script and call it directly

if it works, then php works

- you tried an html form

it didn't post, seems apache is disallowing posts

- check for .htaccess files on your site

if found you need to rename them or remove them

- if no .htaccess or if they are all renamed and the post still doesn't work

then it is an apache config prob

The VPS includes the default apache configuration

apache default conf has post enabled

we can do so at our $90.00/hr tech support rate

fat chance, I wouldn't pay them a cent since they obviously have no idea what they are talking about.

jdMorgan

8:24 pm on May 4, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



> I wouldn't pay them a cent since they obviously have no idea what they are talking about.

If I was losing money, I sure would... But not until the problem is fixed... :)

The only problem I'm having with their tech support (the answers generally seem lucid, if not all that concerned) are their blind refusal to acknowledge that the problem is reportedly with POST, not with the script being POSTed-to. If you use an html form to do the POST, and have it POST to a non-existent script, I'd assume you'll still get the "Method Not Allowed" error. I guess you could try that and see.

The response you got is correct; I assumed you did not have access to the (virtual) server configuration. If you do have access to httpd.conf, then go through it and see if you can find any references to HEAD, GET, PUT, DELETE, POST, TRACE, PROPFIND, etc. or any mention of the word "Method" as in "HTTP Method". If httpd.conf places access restrictions on the POST method, then that would explain your problem.

Jim

curley

10:08 pm on May 4, 2004 (gmt 0)

10+ Year Member



I have a look to "httpd.conf" and I can't see restriction for "cgi" extension or other restrictions.

I check httpd.conf for virtual server and I check main "httpd.conf"

This is from my consultant above...I inserted Jim's comments from your last post and this was his reply.

Why can't this be figured out?

gergoe

10:26 pm on May 4, 2004 (gmt 0)

10+ Year Member


you should not skip the testing of the environment by (for exmaple) following the steps sent by jatar_k, or by just trying to load the php page into the browser and posting some form data to an ordinary html page. by the way, you can do some testing with telnet also, but not an easy way indeed (but very often it helps).

in most of the cases the nastiest problems are caused by a seriously simple mistake/problem.

gergoe

10:30 pm on May 4, 2004 (gmt 0)

10+ Year Member


additionaly if you can gain access to the apache config (not directly indeed, but still), then i suppose you can have the log files produced by your virtual server, then take a look in the error log, that should give the explanation to your problem