Skip to content Skip to sidebar Skip to footer

Maintain Button Submit Value When Using Link To Submit A Form

i am trying to create a link that submits a form. I use this and works fine :

Solution 1:

You can create input type of hidden and check for its existence:

if (isset($_POST['hiddenName'])) {....}

Solution 2:

You can use a hidden field instead. So when the form is submitted, you can check if the hidden element exists.

Like this:

<input type="hidden" name="submit" value="Send Message" />

This way, you can check for $_POST['submit'] when you submit the form. Just make sure the hidden <input> is inside the <form> element, so it will POST with the rest of the form.


Solution 3:

add a hidden input.

<input type="hidden" name="submit" value="Send Message" />

it will not be visible to the user, but it will be send with the form contents.


Solution 4:

You can always hide the submit button (with css display: none) and click it with JavaScript:

document.forms.theForm.elements.submit.click();

Post a Comment for "Maintain Button Submit Value When Using Link To Submit A Form"