Send message after the click of the submit button

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 everything in PHP. !!!

So it is 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{

}
    
asked by anonymous 28.06.2017 / 22:38

3 answers

2

TEST

if (isset($_POST['btn'])){
   echo " O botão foi clicado ";
}else{
   echo "esperando botão ser clicado";
}
    
29.06.2017 / 01:49
1

You should use a medium that relates to POST to check if the button was clicked, see example:

<form action="" method="post">
<input type="text" name="salario"><br/>
<input type="text" name="bonificacao"><br/>
<input type="hidden" name="validar" value="989">
<input type="submit" name="go" value="Vai" />
</form>

<?php
if(isset($_POST['validar'])){
$valida = $_POST['validar'];
if($valida == 989){
echo 'Clicado';
}
}
?>
    
28.06.2017 / 23:36
-1

Try to take the exclamation out of your condition, you're denying the condition.

If it does not work, try this. Put value in submit :

<form  method="POST">
  <input type="text" name="salario"><br/><br/>
  <input type="text" name="bonificacao"><br/><br/>
  <input type="submit" name="btn" value="Botão">
</form>

Whenever you submit it will send the submit, hence you check if it is passing the value:

<?php
  if (isset($_POST['btn']) and ($_POST['btn'] <> "")) {
    echo " O botão foi clicado ";
  } else { }
    
28.06.2017 / 22:51