Jump to content

Best way to check for form submit


kts

Recommended Posts

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.

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..

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.