views:

490

answers:

4

I'm running Firefox 2.0.0.14.

I have a form on a webpage which is working fine with the GET method.

I'm using a plugin to view my browser's HTTP request when submitting the form, and here it is :

GET /postComment.php?review=2&comment=Testing HTTP/1.1
...

However, if I make the simple change from method=GET to method=POST on the form:

GET /postComment.php HTTP/1.1
...

It isn't even attempting to POST.

Any possible reasons for this, under any circumstances?

EDIT: Here is the form:

<form method=POST action="postComment.php"><input type=hidden name=review value="2"><input type=submit value="Postit">
</form>
A: 

Is the action parameter of the form tag set? Could Javascript be intercepting the post? Some HTML from your form would be helpful, or an example link :)

Al
There is no JS on the page whatsoever.
Could you paste the <form> tag and <input type="submit"> you are using please? Are you accidentally duplicating the <form> definition somewhere?
Al
Sure, check the question for edit
Works for me :(
Al
A: 

I'm guessing your plugin is not capturing the POST variables. Since the output of your plugin is:

GET /postComment.php HTTP/1.1

How are you catpuring your POST varables? $_POST['key'] or $_REQUEST['key'] should contain your value if the form action and method are set properly.

POST will not be found in the query string.

EDIT: if you are trying to capture the post value, you can check it with something like this:

if (isset($_REQUEST['submit'])) {
   echo $_REQUEST['review'];
}

or

if (isset($_POST['submit'])) {
   echo $_POST['review'];
}

Acorn

Acorn
I should see:POST /postComment.php HTTP/1.1...Content-Length: xxx[THE POST DATA]
Note: I see the proper POST request from other forms using the plugin
I am checking the POST value like that - isset = false, which is what prompted me to examine the HTTP request using the plugin
What happens when you change the form action to $_SERVER['PHP_SELF']
Acorn
A: 

I would start by making sure your HTML is valid XHTML. Wrap attribute values in quotations and end the input elements with />. Use a valid DOCTYPE.

Also, try changing the value of the submit button to "submit" (as that is the default).

Try it out in different browsers, including the latest version of Firefox.

Peter Di Cecco
A: 

Firstly, your <form> tag needs to be adjusted:

<form method="post" ... >

Secondly, I have a function called debugArray that I use to spit out misbehaving arrays. It's very handy:

function debugArray($array){
    echo("<pre>");
    print_r($array);
    echo("</pre>");
}

Then, call it in your code like this:

debugArray($_POST);

By looking at the entire contents of the $_POST array, you can see exactly what is being sent, what is not, and how it is being sent.

I'm willing to wager that one of the following is true:

  1. You have a spelling mistake in a field name, remembering that names are case sensetive.
  2. Your form field is outside your <form> tags.
  3. You have a value that is not being escaped correctly, or otherwise being dropped from the $_POST for whatever reason.

Edit: And I would also be inclined to update your copy of Firefox.

EvilChookie
I'm using "print_r($_POST)" and getting nothing ("Array( )")I've posted the form code above.
Firefox comment noted, but this is a version bundled with a very popular netbook and so it would be best to support it
If you're seeing a completely empty $_POST array, this means that your Firefox is not correctly posting the information - are you using some form of privacy software? What version of PHP are you using? What browser? What server (apache, windows)?
EvilChookie