php – Insert record in database by clicking div x


How can I insert a record to the database by clicking on a div x

I tried to use ajax but couldn't do the function.

I have the role

$status = "on";
db::Query("UPDATE bdc SET status='$status'");

I wanted to insert this function when clicking on a div div X


Your link:

 <a href="#" id="atualiza">Atualizar</a>

And your Javascript (assuming you use JQuery)

  method: "POST",
  url: "atualizar.php",
  data: { status: "on"}
  .done(function( msg ) {
    alert( "Atualizado!" );

In your update.php file:

function atualizar($status){
db::Query("UPDATE bdc SET status='$status'");

if(filter_input(INPUT_POST, 'status')){
$status = filter_input(INPUT_POST, 'status');
Scroll to Top