8 Replies - 462 Views - Last Post: 22 January 2011 - 02:51 PM Rate Topic: -----

#1 Antiokus  Icon User is offline

  • D.I.C Head

Reputation: 10
  • View blog
  • Posts: 192
  • Joined: 06-September 06

Posting data to database via webpage

Posted 21 January 2011 - 03:16 AM

Looking for some feedback on this one:

I have an application that gathers some stats about usage and things of that sort. And since I have a domain just sitting there I thought it'd be interesting to have the application push those stats to the website to be put into the database.

I've done some similar things before (mostly web requests to some php files I made). This time I'm trying to go about it in a more secure manner. Obviously I don't want to have a page that just executes a SQL query that is passed in. I'm also skeptical of simply passing in the variables and an action flag. I have entertained the thought of a security token that needed to be present.

I'm just unsure if this a very good way of designing this...

Is This A Good Question/Topic? 0
  • +

Replies To: Posting data to database via webpage

#2 Curtis Rutland  Icon User is online

  • (╯□)╯︵ (~ .o.)~
  • member icon


Reputation: 4523
  • View blog
  • Posts: 7,888
  • Joined: 08-June 10

Re: Posting data to database via webpage

Posted 21 January 2011 - 08:13 AM

Web Services are exactly what you need.

Look into WCF web services. Alternatively, you can use ASP.NET's web service (ASMX).
Was This Post Helpful? 0
  • +
  • -

#3 Antiokus  Icon User is offline

  • D.I.C Head

Reputation: 10
  • View blog
  • Posts: 192
  • Joined: 06-September 06

Re: Posting data to database via webpage

Posted 21 January 2011 - 05:42 PM

Suppose I should have mentioned that the host for my site is linux/apache.
Was This Post Helpful? 0
  • +
  • -

#4 Sergio Tapia  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 1253
  • View blog
  • Posts: 4,168
  • Joined: 27-January 10

Re: Posting data to database via webpage

Posted 21 January 2011 - 06:17 PM

Can you tell us why you posted this in the C# subforum?
Was This Post Helpful? 0
  • +
  • -

#5 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6074
  • View blog
  • Posts: 23,540
  • Joined: 23-August 08

Re: Posting data to database via webpage

Posted 21 January 2011 - 07:01 PM

Well, then just use WebClient or HttpWebRequest to POST the data.
Was This Post Helpful? 0
  • +
  • -

#6 Curtis Rutland  Icon User is online

  • (╯□)╯︵ (~ .o.)~
  • member icon


Reputation: 4523
  • View blog
  • Posts: 7,888
  • Joined: 08-June 10

Re: Posting data to database via webpage

Posted 21 January 2011 - 07:22 PM

Well then, you won't be able to use C# for the server piece. You could write a REST web service using PHP, Python, Ruby, etc... but I don't know how skilled you are with those. You also should be able to set up your DB to allow remote connections, though that's risky to the point of foolishness.
Was This Post Helpful? 0
  • +
  • -

#7 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6074
  • View blog
  • Posts: 23,540
  • Joined: 23-August 08

Re: Posting data to database via webpage

Posted 22 January 2011 - 04:54 AM

I'm confused about which side the OP is looking for help with. Is it client AND server? There's no reason you can't do a simple PHP server page which saves the data to the DB and post to it from a C# client.
Was This Post Helpful? 1
  • +
  • -

#8 Antiokus  Icon User is offline

  • D.I.C Head

Reputation: 10
  • View blog
  • Posts: 192
  • Joined: 06-September 06

Re: Posting data to database via webpage

Posted 22 January 2011 - 02:39 PM

It was posted in the C# forum because the application was written in C#. Figured that would be implied but I suppose not...

Either way, I was trying to find out if I should continue using a PHP form that handles transactions to the DB and then just posting to it (as Jack said). I'm not having trouble with the system, just wanting to make sure there wasn't some other, potentially better, way of designing it.

It may not be ideal but I'm kind of limited in my ability to use web services and write my own server since the site is hosted and I'd rather not enable remote connections.

Thanks everyone
Was This Post Helpful? 0
  • +
  • -

#9 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6074
  • View blog
  • Posts: 23,540
  • Joined: 23-August 08

Re: Posting data to database via webpage

Posted 22 January 2011 - 02:51 PM

OK, my personal recommendation would be to set up certificate authentication and use HTTP with certificates as your authentication mechanism.

It's also quite possible to use PHP's SOAP library to create a SOAP, i.e. Web Services, front-end with which you could use WCF as noted above. Again, you can use whatever auth mechanism you'd like.

Don't forget to use SSL as well.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1