Click here to Skip to main content
15,893,722 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
My partner is creating an android app and I am working on its back-end side.
We need to fetch data from database located on the server to our app.
I am familiar to design web handler/web services to handle remote requests in asp.net.

Please guide me on how to create a web handler in PHP to retrieve some data from tables and send it to remote request device. Which one would be better to use PHP or ASP.net for our purpose?

I am uploading a sample program that I created in ASP.net to handle the requests (I guess this sample program has nothing to do with my question but still I believe it would help)

C#
<%@ WebHandler Language="C#" Class="DefaultLocationHandler" %>

using System;
using System.Web;

public class DefaultLocationHandler : IHttpHandler {
    
    public void ProcessRequest (HttpContext context) {
        int username = Convert.ToInt32(context.Request.Params["username"].ToString());                                                                           
        decimal password =Convert .ToDecimal ( context.Request.Params["password"].ToString());
        decimal email =Convert .ToDecimal ( context.Request.Params["Email"].ToString());


        SqlConnection con = new SqlConnection("Data Source=103.21.58.192;Initial Catalog=Helper;User ID=avi_Helper;Password=xyz2515");
        con.Open();
        string str = @"Insert into [Helper].[dbo].[Default_Location]  
		      ([User_Number]
		      ,[Default_Latitude]
		      ,[Default_Longitude])
		     VALUES ('" + username + "'," + password + "," + email + ")";

        SqlCommand cmd = new SqlCommand(str, con);
        cmd.ExecuteNonQuery();
        con.Close();
        context.Response.Write("Inserted" + username);
    }
    
 
    public bool IsReusable {
        get {
            return false;
        }
    }
}
Posted
Updated 5-Sep-15 20:51pm
v2

1 solution

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900