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
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.

Link to comment
Share on other sites

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?

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.