I am validating user access using the traditional method:
IwouldlikethismessagetoappearinaModalBootstrap.Itriedthecodebelow,butthemodalbackgroundappears(black)andclosesquickly,doesnotkeepthemodalopen:
HTML
<formmethod="post" id="login-form">
<li>
<label id="texto">Login:</label>
<input required="required" type="text" name="LoginAcesso" id="usuario" placeholder="Matrícula" class="form-control" />
</li>
<li>
<label>Senha:</label>
<input required="required" type="password" name="SenhaAcesso" id="password" placeholder="Senha" class="form-control" />
</li>
<li class="text-right">
<button type="submit" name="submit" id="botao" class="btn btn-primary">Acessar</button>
</li>
</form>
MODAL
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">Login e senha inválidos</h4>
</div>
<div class="modal-body">
<p>Tente novamente.</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Fechr</button>
</div>
</div>
</div>
</div>
JQUERY
<script type="text/javascript">
$(document).ready(function(){
$('#login-form').submit(function(){
var login = $('#username').val();
var senha = $('#password').val();
$.ajax({
url : 'validar.php',
type : 'POST',
//dataType:"json",
data : 'login='+login+'&senha='+senha,
//beforeSend : function(){
// alert('01');
// $('#myModal').modal('show');
// },
success : function(data){
alert(data);
if(data == 1){
$('#myModal').modal('show');
}else{
alert('02');
}
}
});
});
});
</script>
VALIDAR.PHP
<?php
echo 1; // Teste
?>