I have a php form and in this form a modal, to open the modal a button type link. When clicking the link the modal opens normally, however, when I click the save button of the modal open it executes the form php and the modal does not insert data from the database How can I perform one button at a time? One for the modal (without it loading any other form which one is) and the button that just loads the form
<form method='post' action='dir/action.php'>
<div class='box box-primary'>
...
<!--MODAL -->
...
<!--BUTTONS MODAL-->
<div>
<input name="salvarModal" type="submit" class="btn bg-green"
id="salvarModal" value="Cadastrar" />
<button type="button" class="btn btn-danger" data-
dismiss="modal">Fechar</button>
</div>
<!--END BUTTONS MODAL -->
<!--PHP CODE FOR MODAL INSERT DATABASE -->
if(@$_POST["salvarModal"]){
$local = $_POST["localNovo"];
$AddCat = $PDO->query("INSERT INTO database_ex (local) VALUES
('$local')");
if($AddCat){
echo '<script type="text/JavaScript">alert("Local Adicionado ! ");
location.href="index.php?p=newaction"</script>';
}else{
echo '<script type="text/javascript">alert("Error");</script>';
}
}
?>
...
<button type="submit" class="btn btn-primary">SAVE</button>