nyanev
nyanev

Reputation: 11519

Use JSON in Iphone Application

I'm developing Iphone app with registration form. I want to check if the username is available. I think this could be done with call of php script on remote server. Php script should return json object if the username is in use. Is this the right way? Thanks :)

Cheers

Upvotes: 0

Views: 526

Answers (2)

agough
agough

Reputation: 605

Yes that is a perfectly valid approach. You'll need to add JSON parsing to your app as there is no native support in Objective-c/cocoa touch, SBJSON http://stig.github.com/json-framework/ is a good option. asi-http-request may also be helpful for making the http request.

Upvotes: 2

gunwin
gunwin

Reputation: 4832

Get your php login script to accept post vars (username & password) and output true if correct and something else if incorrect. Then use

$.post("loginscript.php", { username: $("#myusernamefield").val(), password: $("#mypasswordfield").val() },
function(data) {
    if(data == "true")
    {
        alert("Successful login");
    } else {
        alert("login failed");
    }
});

Upvotes: 0

Related Questions