Home/Creating Backend Web Service for a Mobile Application (iPhone, Android, BlackBerry) using PHP

Creating Backend Web Service for a Mobile Application (iPhone, Android, BlackBerry) using PHP

Published On: 3 November 2011.By .
  • Product & platform Engineering

Web services are basically used for backend support for mobile apps. That means if we have to make an app which will use to save any kind of data in database or have login, registration etc. services or have to upload images, videos using mobile (iPhone, Android, Blackberry) app than we have to create a frontend or we can say it GUI for user view and a backend for support.

Step 1:For web service firstly we have to generate a URL with some segments through which we will call different services for login, registration etc.



Step 2:This URL called by frontend and services we have to get in backend using $_GET.$j_deco=json_decode(stripslashes($_GET[‘json’]));

Step 3: This will give us decoded form of the above URL.

Step 4: After decoding we will get action using $action = $_GET[‘action’], and make a switch case to call a particular function for particular action.

switch ($action)


case “login”:

$email=$j_deco[0]->email;                                    //It will get email

$pass=$j_deco[0]->password;                               //It will get password

Login($email,$pass));                                            //Function Calling



Step 5: Now the final function for login service.

function Login($email=NULL, $pass=NULL)


$arrayList = array();

$login_qry=”select id,email from user_login where email=’$email’ and  password=’$pass'”;





$arrayList[] = $result;







$arrayList[] = $result;


echo json_encode($arrayList);                                    //return encoded form of result.


Step 6: Finally the encoded result reached to frontend whenever the service will called as shown in the screenshot above.

Related content

We Love Conversations

Say Hello
Go to Top