Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP won't return a response

Tags:

jquery

ajax

php

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);  
?>
like image 649
user1072910 Avatar asked Jan 19 '26 09:01

user1072910


1 Answers

Its very simple you are posting your username as usern and password aspword

So it should be

<?php   
    $username=$_POST['usern'];  
    $password=$_POST['pword'];  
like image 152
Gautam Avatar answered Jan 20 '26 22:01

Gautam



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!