Ajax post to php serverside code

This is home work and I was given some Ajax javascript code I need to modify. I am having trouble figuring out the syntax of some of the code.

Here is the provided code and I am suppose to write the php serverside code

function submit_login() {
    if( document.form.loggedIn.checked ) return
    request = new XMLHttpRequest()
    request.onreadystatechange = respond_login
    request.open("POST", "AjaxController.php", true /* asynchronous? */ )
    request.send( "action=login&password=" + postEscape( document.form.pwd.value ) +
                    "&username=" + postEscape( document.form.user.value ))
    document.form.pwd.value = ""
    document.form.user.value = ""
}

I am confused on how to write the server side part for the POST. Normally I would write something like this:

$action = $_POST['"action=login&password="];

However I am confused as how to write the above line since two variable are passed through the send. I think I need to parse it but I still find this line confusing as to whats happening.

Answers


At the server side you fetch the values with 3 statements:

$action = $_POST['action'];
$username = $_POST['username'];
$password = $_POST['password'];

Need Your Help

C function to capitalize first letter of words in an array

c arrays string function toupper

I'm pretty new to C and am hitting a wall when creating the below function. I want to use this function to make the first letter of a word upper case for a static character array (char string[]. It

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.