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?

Recommended Answers

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 …

Jump to Post

All 2 Replies

try

if($_POST['save_msg'])

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.