i want to create login system in php using ajax here is my code
jQuery(document).ready(function ($) {
// login function
$('form#login').on('submit', function(){
var url = document.getElementById('hidden').innerHTML;
var login_result = $('.login_result');
var input_data = $('form#login').serialize() + "&action=login";
$.ajax({
type: "POST",
data: input_data,
url: url + 'lib/my_func.php',
success: function(responseText){ // Get the result and asign to each cases
if(responseText == 0){
login_result.html('<span class="error">Username or Password Incorrect!</span>');
}
else if(responseText == 1){
window.location = 'userpage.php';
}
else{
alert('Problem with sql query');
}
}
});
return false;
});
});
and here is my php function
function login()
{
if(isset($_POST['action']) && $_POST['action'] == 'login')
{
$user = $_POST['login'];
$pas = $_POST['password'];
echo $user;
}
}
but in this php login function there in no output. and if i remove function echo $user is true, how to echo $user in login function please help me
login();login();under the end of the function so that it is actually is called to start your verification process.