$("#something-%"). submit(function(e) { e. preventDefault(); $("#some-span"). html(data); });
Add type property with submit type="submit" to button tag this will submit the form then receive the form inputs value in php script with super global variable $_POST['input name'] or $_GET[] wdepends on from action property value by default GET.
For general check if there was a POST
action use:
if (!empty($_POST))
EDIT: As stated in the comments, this method won't work for in some cases (e.g. with check boxes and button without a name). You really should use:
if ($_SERVER['REQUEST_METHOD'] == 'POST')
How about
if($_SERVER['REQUEST_METHOD'] == 'POST')
Actually, the submit button already performs this function.
Try in the FORM:
<form method="post">
<input type="submit" name="treasure" value="go!">
</form>
Then in the PHP handler:
if (isset($_POST['treasure'])){
echo "treasure will be set if the form has been submitted (to TRUE, I believe)";
}
Use
if(isset($_POST['submit'])) // name of your submit button
if ($_SERVER['REQUEST_METHOD'] == 'POST')
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With