-1

I had a code, which was working OK.

echo "<form name='pm_form' method='post' action='?inbox'>\n";
echo "<input type='submit' name='save_msg' value='Save' class='button' />\n";
echo "</form>\n";

Poor quality button, I changes to a well looking image:

echo "<form name='pm_form' method='post' action='?inbox'>\n";
echo "<input type='image' src='button_save.png' value='Save' name='save_msg'/>";
echo "</form>\n";

But the problem is, that my execution code, after button was pressed, stoped to work:

if (isset($_POST['save_msg'])) {
<.... DO THE QUERIES ...>
}

It works on Mozilla Firefox, but do not work in IE or Opera. As I understand, the $_POST aren't submitting in the second case.

So, what solutions do you suggest solving this problem?

3
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by Atli
1

Hey.

When you submit the form using a type="image" button, or submit the form using the enter key, some browsers do not pass the button along with the data.

To circumvent this, and assure that your test will work on all browsers, always use the if(isset($_POST['xxx'])) test on a data field rather then the button. It is also common to create an extra hidden input field for the sole purpose of testing if the form has been submitted.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.