Ejemplo 1: ajax jquery php
<!doctype html><html><head><script src="https://code.jquery.com/jquery-3.3.1.js" integrity="sha256-2Kok7MbOyxpgUVvAk/HJ2jigOSYS2auK4Pfzbm7uH60=" crossorigin="anonymous"></script></head><body><form id="loginform" method="post"><div>Username:<input type="text" name="username" id="username"/>Password:<input type="password" name="password" id="password"/><input type="submit" name="loginBtn" id="loginBtn" value="Login"/></div></form><script type="text/javascript">
$(document).ready(function()
$('#loginform').submit(function(e)
e.preventDefault();
$.ajax(type:"POST",url:'login.php',data: $(this).serialize(),success:function(response)var jsonData =JSON.parse(response);// user is logged in successfully in the back-end// let's redirectif(jsonData.success =="1")
location.href ='my_profile.php';elsealert('Invalid Credentials!'););););</script></body></html>
Ejemplo 2: proyecto ajax usando php y jquery
if(isset($_POST['username'])&&$_POST['username']&&isset($_POST['password'])&&$_POST['password'])// do user authentication as per your requirements// ...// ...// based on successful authenticationechojson_encode(array('success'=>1));elseechojson_encode(array('success'=>0));
¡Haz clic para puntuar esta entrada!
(Votos: 0 Promedio: 0)