I have a modal form, in which when you press save (submit) the fields are checked, type that you do not have any empty and such and then the values are sent.
I would like to make, within my function, that when everything is correct, we look at a variable of $ _session that contains a profile, if it is a profile it is "invited" you get an alert ("You do not have permissions! ") and the modal is closed (without sending anything obviously)
How could I fix my function to do that?
This is my modal with onsubmit="return validaCampos();">
<div class="modal" id="nuevoUsu" tabindex="-1" role="dialog" aria-labellebdy="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h4 class="modal-title"><span class="glyphicon glyphicon-plus-sign"></span>Nuevo Producto</h4>
</div>
<div class="modal-body">
<form action="insertar.php" method="GET" onsubmit="return validaCampos();">
<!--campos del formulario--->
<input type="submit" class="btn btn-success" value="Salvar">
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-warning" data-dismiss="modal">Cerrar</button>
</div>
</div>
</div>
</div>
Here I have the feature
<script>
function validaCampos(){
//etc
//etc
//etc
if(cantidad < 0){
toastr.error("Mínimo permitido 0","Aviso!");
return false;
}
////////////////////// Aquí supongo que seria la funcion
<?php
if($_SESSION['perfil']=="invitado"){
?>
alert("No tienes permisos, eres invitado");
dialog.dismiss();
<?php
}
?>
/////////////////////
}
</script>
The alert is shown to me but the modal is not closed and the data is sent
How could I solve it?
Thank you.