title: C# how to post data with specific submit name (ID)
body: <p>What i need is to post data and get result without browsing the page , the php page i should post to has an if statement checks if the post was through the submit button,
  to make things more clear lets say i have this page</p>
  
  <pre class="lang-html prettyprint-override"><code>&lt;form action="test2.php" method="post" name="myphpform" onSubmit="return checkForm()"  &gt;
  &lt;table border=0&gt;
  &lt;tr&gt;
      &lt;td&gt;Your Name:&lt;/td&gt; &lt;td&gt;&lt;input type="text" name="yname" size="50"    maxlength="50" value="" /&gt;&lt;/td&gt;
  &lt;/tr&gt;
  
  &lt;tr&gt;
      &lt;td&gt;Your Email:&lt;/td&gt; &lt;td&gt;&lt;input type="text" name="email" size="50" maxlength="50" value="" /&gt;&lt;/td&gt;
  &lt;/tr&gt;
  
  &lt;tr&gt;
      &lt;td&gt;Message:&lt;/td&gt; &lt;td&gt;&lt;input type="text" name="message" size="50" maxlength="50" value="" /&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
      &lt;td&gt;Are you a human being?&lt;/td&gt;
      &lt;td&gt;
   &lt;td&gt;&lt;input type="submit" name="submitname" value="submitvalue" /&gt;&lt;/td&gt;
  
  
   if ($_POST["submitname"]) 
   {
    //echo "Post succeeded";
   }
  </code></pre>
  
  <p>now if i use any method to post data to that page i get response with the page body itself not the "Post succeeded" Msg, when i changed the condition to </p>
  
  <pre><code> if ($_POST)
     {
        //echo "Post succeeded";
     }
  </code></pre>
  
  <p>i get the succeeded msg</p>
  
  <p>this is the method i am using</p>
  
  <pre><code>System.Net.WebRequest req = System.Net.WebRequest.Create(URI);
  string PostData = "Post Test data";
  req.ContentType = "application/x-www-form-urlencoded";
  req.Method = "POST";
  byte[] bytes = Encoding.UTF8.GetBytes(PostData);
  req.ContentLength = bytes.Length;
  System.IO.Stream os = req.GetRequestStream();
  os.Write(bytes, 0, bytes.Length);
  os.Close();
  System.Net.WebResponse resp = req.GetResponse();
  </code></pre>
  
  <p>i wanna know is there a way to post the data and trigger the if statement ?
  thanks in advance</p>