tags:

views:

53

answers:

3

Hi,

I have a website that is primarily PHP but we have built some new pages in c# .net. I need to be able to post (i think) to the PHP page.

The PHP page has a login that takes the login name and password. I am trying to allow my .net page to have a login that directs to the PHP page and once there the user is already logged in.

I believe I can post the data to the PHP page... is that correct?

If so, can someone share a code snippet that points me in the right direction?

Thanks for the help!!

A: 

I believe there is a cURL version for c#, the easy way would be to set that up if you can. Some information on using cURL with .NET can be found here and there are a few other resources on Google for c# curl

Brad F Jacobs
A: 

There are lots and lots of ways. I prefer javascript ( with jquery) ajax calls

$.post('login.php', function(data) {
  alert( "returned " + data + " from php page");
});

see jQuery documentation for more details.

If you need to do this serverside (in the c# code behind), let me know, I will write up some sample code.

BioBuckyBall
A: 

There's no difference between submitting a form post to a PHP script or to a C# application or to whatever program written in whatever language. How the data is transferred is defined by Internet standards.

Of course, different implementations may have slightly different behaviors. For instance, PHP considers all input names that have square brackets in their name to be part of an array.

Artefacto
If that's the case, can't I do something like the following:WebRequest wr = WebRequest.Create("http://some.php.page");wr.Method = "POST";wr.ContentType = "application/x-www-form-urlencoded";string sDataToPost = "Name=UserNameStream rs = wr.GetRequestStream();StreamWriter sw = new StreamWriter(rs);sw.Write(sDataToPost);
Tony