richs Posted January 23, 2011 Share Posted January 23, 2011 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? Quote Link to comment https://forums.phpfreaks.com/topic/225370-posting-from-c-app-to-php-form/ Share on other sites More sharing options...
azuka Posted January 23, 2011 Share Posted January 23, 2011 Have you tried urlencoding using HttpUtility.UrlEncode()? Quote Link to comment https://forums.phpfreaks.com/topic/225370-posting-from-c-app-to-php-form/#findComment-1163853 Share on other sites More sharing options...
richs Posted January 23, 2011 Author Share Posted January 23, 2011 I'm using Encoding.UTF8 on the c# side. Quote Link to comment https://forums.phpfreaks.com/topic/225370-posting-from-c-app-to-php-form/#findComment-1163855 Share on other sites More sharing options...
requinix Posted January 23, 2011 Share Posted January 23, 2011 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. Quote Link to comment https://forums.phpfreaks.com/topic/225370-posting-from-c-app-to-php-form/#findComment-1163857 Share on other sites More sharing options...
richs Posted January 23, 2011 Author Share Posted January 23, 2011 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? Quote Link to comment https://forums.phpfreaks.com/topic/225370-posting-from-c-app-to-php-form/#findComment-1164002 Share on other sites More sharing options...
richs Posted January 23, 2011 Author Share Posted January 23, 2011 Bad news for me. I think I've got a c# problem. I don't seem to be posting the url with the attached parameter sting. When I post to the page with a built up parameter sting everything works fine. Quote Link to comment https://forums.phpfreaks.com/topic/225370-posting-from-c-app-to-php-form/#findComment-1164018 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.