2
How do I identify with PHP if a Submit button was clicked? and after the click I want to send a click confirmation message. Detail all in PHP.!!!
So it’s not working not
<form method="POST">
<input type="text" name="salario"><br/><br/>
<input type="text" name="bonificacao"><br/><br/>
<input type="submit" name="btn">
</form>
<?php
$btn = $_POST['btn'];
if(!$btn){
echo " O botão foi clicado ";
}else{
}
Doesn’t it even work when you press the button? Once you load the page the first time is expected to go wrong, as you will be making a GET request and retrieving POST values that do not exist. In fact, why the condition in the
if
is!$btn
?– Woss
There’s a time when a message appears without being clicked
– Julio Silva
I believe the problem is at first access a Warning of
undefined index
is generated because the$_POST
there is still noisset()/empty()
should solve, for more details see How to know if the form is sent and When isset is required?– rray