<div class="wrap-user">
<div class="container">
<div class="wrap-user__in">
<aside class="wrap-user__aside">
<header class="wrap-user__header wrap-user__header--inline-small">
<a href="#" class="wrap-user__header__link">o BIEN CREATE AUNA CUENTA</a>
<h1 class="wrap-user__header__title h5user2">Inicia Sesión</h1>
</header>
<p class="puser2">En Depildiodo protegemos todos los datos de forma segura (HTTP/SSL)</p>
</aside>
<main class="wrap-user__content">
<div class="form">
<h5 class="h5user">INICIA SESIÓN CON TU CUENTA</h5>
<form name="login">
<label style="color: #737373;font-weight: 100;">EMAIL</label>
<div class="form-group" style="margin-bottom: 28px;">
<input type="text" class=" my-form-control" id="username" name="username" placeholder="[email protected]" required />
</div>
<label style="color: #737373;font-weight: 100;">CONTRASEÑA</label>
<div class="form-group">
<input type="password" id="password" class=" my-form-control" name="password" placeholder="minimo 4 cararcteres" required />
</div>
<div class="col-lg-12" style="text-align: left; margin-top: 5%; padding: 0px;">
<input name="chec" class="chzxc" type="checkbox" id="chec" onChange="comprobar(this);"/>
<label class="aceptatm">He leído y acepto la <a href="aviso_legal.php">Términos y Condiciones</a></label>
</div>
<div id="respuesta">RESPUESTA</div>
<input name="submit" id="submit" type="submit" class="btnLogin" value="Iniciar Sesión" disabled />
</form>
</div>
</main>
</div>
</div>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
$("#submit").click(function(e){
e.preventDefault();
var post=$.post('respuesta.php',{
funcion:'FUNCION',
username:$("#username").val(),
password:$("#password").val(),
},function(msg){
if(msg=="1"){
window.lcoation="index.php";
}else{
$("#respuesta").html(msg);
}
});
});
});
</script>
<?php
require('conexion/conexion.php');
@session_start();
if($_POST["funcion"]=="FUNCION"){
$username = stripslashes($_REQUEST['username']$_POST['username']);
$username = mysqli_real_escape_string($mysqli,$username);
$password = stripslashes($_REQUEST['password']$_POST['password']);
$password = mysqli_real_escape_string($mysqli,$password);
$query = "SELECT * FROM Usuarios WHERE Username='$username'";
$result = mysqli_query($mysqli,$query) or die(mysql_error());
$rows = mysqli_num_rows($result);
if($rows==1){
$_SESSION['username'] = $username;
$_SESSION['password'] = $password;
echo "1";
//header("Location: mi-cuenta.php");
}else{
?>
<div class='form'>
<h3>Username/password is incorrect.</h3>
<br/>Click here to <a href='login.php'>Login</a>
</div>
<?php
}
exit();
}
?>