i have used following code in my c# application
string verification_url = @"http://site.com/posttest.php?";
string verification_data = "test=524001A";
string result = string.Empty;
result = Post(verification_url, verification_data);
public string Post(string url, string data)
{
string result = "";
try
{
byte[] buffer = Encoding.GetEncoding(1252).GetBytes(data);
HttpWebRequest WebReq = (HttpWebRequest)WebRequest.Create(@url);
WebReq.Method = "POST";
WebReq.ContentType = "application/x-www-form-urlencoded";
WebReq.ContentLength = buffer.Length;
Stream PostData = WebReq.GetRequestStream();
PostData.Write(buffer, 0, buffer.Length);
PostData.Close();
HttpWebResponse WebResp = (HttpWebResponse)WebReq.GetResponse();
Stream Answer = WebResp.GetResponseStream();
StreamReader _Answer = new StreamReader(Answer);
result = _Answer.ReadToEnd();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
if (result.Length < 0)
result = "";
return result;
}
Server side PHP code
<?php
$test=$_REQUEST['test'];
echo $test;
?>
post method always returns empty value
please help me