Jump to content

Best way to check for form submit


kts

Recommended Posts

I have used many different ways, what is the safest best way to do it for all server types.

 

I've done if(isset($_POST['submit'])) doesn't always work, and checked for a hidden fields value to be 1, etc... I'm curious thanks.

 

 

 

Link to comment
Share on other sites

make sure that the submit button in your form is as such.

 

<button type="submit" name="submit" value="1">Click Here</button>

 

$_POST['submit'] reads off the name attribute, and will contain "1". As long as your submit button has a name and a value, isset($_POST['submit']); will always work.

Link to comment
Share on other sites

I have a form right now....

 

 

if(isset($_POST['submit'])){

 

do stuff

 

}

 

 

<input type="image" name="submit" value="submit" src="submit.jpg" />

 

 

form is not catching... thats why I was wondering, maybe its a server setting being funky? i dont know..

Link to comment
Share on other sites

In reference to your original question, this is the way I usually do it.  (obviously this won't work for every situation)

<?php
if (isset($_POST['action'])) {
    // do phpz
}
?>
<form method="post" action="index.php">
    <input type="submit" name="action" value="Submit" />
</form>

 

I never name my submit buttons 'submit' because this causes problems with javascript.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.