I am carrying out a new functionality with my login and it is that I require that when entering your session, that is, after entering with your username and password, a modal window is loaded immediately, I attach below a small code fragment with which I am making my login:
function EnterLogin(){
if($('#username').val() != '' && $('#password').val() != '')
{
$('.load').show();
$.ajax({
type: "POST",
async: false,
data: {
param: 1,
username: $('#username').val(),
password: $('#password').val()
},
url: "test.php",
dataType: 'JSON',
success: function(data) {
$('.load').hide();
if(data.length){
for(i=0;i<data.length;i++){
if(data[i]['valido'] == 1){
$.ajax({
type: "POST",
async: false,
data: {
param: 3,
username: $('#username').val()
},
url: "test.php",
dataType: 'JSON',
success: function(data) {
if(Parametro ==null){
window.location='test.php';
}
}
});
}else{
alert("Validate username or password");
}
}
}else{
alert("Validate username or password");
}
}
});
}else{
alert("Please enter username or password");
}
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<div class="container">
<div class="form-group">
<label for="username">Username:</label>
<input id="username" type="text" name="username" class="form-control" required/>
</div>
<div class="form-group">
<label for="password">Password:</label>
<input id="password" type="password" name="password" class="form-control" required/>
</div>
<button class="btn btn-default" id="login" onclick ="EnterLogin()">ENTER</button>
</div>
The modal window that I want to open is the following:
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<div class="modal fade" id="basicModal" tabindex="-1" role="dialog" aria-labelledby="basicModal" 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" id="myModalLabel">Basic Modal</h4>
</div>
<div class="modal-body">
<h3>Modal Body</h3>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary">Save changes</button>
</div>
</div>
</div>
</div>