Salve a tutti, ho scaricato un template per amministrazione, originalmente nella pagina login.php è un file jquery che prende i dati dal form e li invia ad un'altra pagina che si connette al db e da un risultato.
Bando alle ciance.
login.php:
codice HTML:
<form method="post" role="form" id="form_login">
<div class="form-group">
<div class="input-group">
<div class="input-group-addon">
<i class="entypo-user"></i>
</div>
<input type="text" class="form-control" name="username" id="username" placeholder="Username" autocomplete="off" />
</div>
</div>
<div class="form-group">
<div class="input-group">
<div class="input-group-addon">
<i class="entypo-key"></i>
</div>
<input type="password" class="form-control" name="password" id="password" placeholder="Password" autocomplete="off" />
</div>
</div>
<div class="form-group">
<button type="submit" class="btn btn-primary btn-block btn-login">
<i class="entypo-login"></i>
Login In </button>
</div>
</form>
<script src="<?php echo ADMIN_URL; ?>assets/js/neon-login.js"></script>
neon-login.js:
codice HTML:
var neonLogin = neonLogin || {};
;(function($, window, undefined){
"use strict";
$(document).ready(function() {
neonLogin.$container = $("#form_login");
// Login Form & Validation
neonLogin.$container.validate({
rules: {
username: {
required: true
},
password: {
required: true
},
},
highlight: function(element){
$(element).closest('.input-group').addClass('validate-has-error');
},
unhighlight: function(element) {
$(element).closest('.input-group').removeClass('validate-has-error');
},
submitHandler: function(ev)
{
/* Login form now processes the login data */
$(".login-page").addClass('logging-in');
// This will hide the login form and init the progress bar
// Hide Errors
$(".form-login-error").slideUp('fast');
// We will wait till the transition ends
setTimeout(function()
{
var random_pct = 25 + Math.round(Math.random() * 30);
// The form data are subbmitted, we can forward the progress to 70%
neonLogin.setPercentage(40 + random_pct);
// Send data to the server
$.ajax({
url: 'heart/RYVAjax.php',
method: 'POST',
dataType: 'json',
data: {
username: $("input#username").val(),
password: $("input#password").val(),
},
success: function(response)
{
// Login status [success|invalid]
var login_status = response.login_status;
// Form is fully completed, we update the percentage
neonLogin.setPercentage(100); // We will give some time for the animation to finish, then execute the following procedures
setTimeout(function()
{
// If login is invalid, we store the
if(login_status == 'true')
{
window.location = "index.php";
}
else
{
// Redirect to login page
setTimeout(function()
{
$(".login-page").removeClass('logging-in');
neonLogin.resetProgressBar(true);
}, 400);
}
},1000);
}
});
}, 650);
}
});
RYVAjax.php
Codice PHP:
$action = $_POST['action'];
switch ($action) {
case 'checkLogin':
$logged = $login->userLogin($_POST['username'], $_POST['password']);
if($logged === true)
echo json_encode("true");
break;
RYVAjax.php fa il controllo su un altro file che si connette al db ecc, quindi se logged is true mi restituisce true
Se provo a fare il login su login.php mi carica la barra fino al 70% e si blocca non mi da ne l'errore ne niente.
Grazie anticipatamente.
Mi scuso per il codice disordinato ma non riesco a sistemarlo.