Jump to content

Posting from C# app to php form


richs

Recommended Posts

I have a .net console app that needs to post data to a web page on a godaddy.com server. I think I'm building the post part on the console application OK but the values are not getting to the php form on the server.

 

INSERT INTO `h0mm0n`.`sensors` (`t0` ,`t1` ,`timeStamp` ,`dbTimeStamp` ,`recordCounter`)

VALUES ( '". $_REQUEST['t0'] ."',  '". $_REQUEST['t1'] ."',  '". $_REQUEST['dt'] ."', CURRENT_TIMESTAMP , NULL)";

 

I'm doing a post from my c# app and the URL string is:

 

"t0=92.52&t1=13.49&dt=2011-01-22 23:09:23Z"

 

If I put the form name and values in a url the values get added to the database OK.

 

What am I missing?

Link to comment
https://forums.phpfreaks.com/topic/225370-posting-from-c-app-to-php-form/
Share on other sites

Two different things. HttpUtility.UrlEncode is like PHP's urlencode() while Encoding.UTF8 is just a text encoding (the "equivalent" would be utf8_encode() and utf8_decode()).

 

Try UrlEncode-ing the data. Especially the date.

On the PHP side, see what

print_r($_REQUEST);

gives you.

Thanks for the replies. I built a form that looks like this:

 

<?php

 

print_r($_REQUEST);

 

?>

 

and I get back:

 

Array

(

)

 

in my C# app I'm doing

 

using (StreamWriter _Writer = new StreamWriter(_Request.GetRequestStream(), Encoding.UTF8))

 

What kind of encoding should I be using?

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.