It's probably something really basic but I've been at it for a while and it's not jumping out at me and I guess I'm tired...please help.
I'm trying to create a simple login html page, read it using jquery/ajax and have php verify it. Here are the 2 pieces the javascript/jquery and the php. While firebug seems to correctly report that "message" is being set, nothing comes back as response...what am I doing incorrectly? And if php did report an error, where do I look for it?
login.js
$(document).ready(function(){
$('#loginForm').submit(function(){
var usern=$('#username').val();
var pword=$('#password').val();
$.ajax({
url: 'mylogin.php',
data: 'action=login&usern='+usern+'&pword='+pword,
dataType: 'json',
type: 'post',
success: function (j) {
$('#loginmessage').html(j.msg);
},
});
});
});`
mylogin.php
<?php
$username=$_POST['username'];
$password=$_POST['password'];
$retval['msg']="in mylogin.php";
fb($retval,"return output from login");
echo json_encode($retval);
?>
Its very simple you are posting your username as usern and password aspword
So it should be
<?php
$username=$_POST['usern'];
$password=$_POST['pword'];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With