title: Sending POST request to page with multiple forms
body: <p>I have found <a href="http://geekswithblogs.net/rakker/archive/2006/04/21/76044.aspx" rel="nofollow">this great class</a> for sending POST request to a webpage. Now I tried it on a test page with single form and it works. But now I would like to do a POST request to a page, that has multiple forms on the same page. Is it possible to select specific form, if it is defined with name?</p>
  
  <p>For example, like this:</p>
  
  <pre><code>&lt;form method="post" action="index.php" target="_parent"&gt;
  ...
  &lt;/form&gt;
  &lt;form method="post" action="index.php" name="login" target="_top" class="login"&gt;
  // This is the form that I want to post data
  ...
  &lt;input value="Go" type="submit" id="input_go" /&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p><strong>EDIT:</strong></p>
  
  <p>This solution provided by Anfurny does not work:</p>
  
  <pre><code>post.PostItems.Add("login", "input_go");
  </code></pre>
  
  <p>I have updated code, the button that submits has only id defined.</p>
  
  <p><strong>EDIT2:</strong></p>
  
  <p>I have found a good example of a page with two forms. <a href="http://demo.phpmyadmin.net/STABLE/index.php" rel="nofollow">phpMyAdmin demo</a>, it has two forms, one is for selecting different language, the other is for login. This demo has:</p>
  
  <ul>
  <li>username = root</li>
  <li>password is empty</li>
  </ul>
  
  <p>Now I have tried to login programmatically with this code (it uses class that I have posted the link on start of the page):</p>
  
  <pre><code>// First we create an instance of a class PostSubmitter.
  PostSubmitter post = new PostSubmitter();
  
  // We set the URL to which the POST should go.
  post.Url = "http://demo.phpmyadmin.net/STABLE/index.php";
  
  // We add items (password and username).
  post.PostItems.Add("pma_username", "root");
  post.PostItems.Add("pma_password", "");
  
  // Also tried to add to which login form should post and the
  // value set to id of the submit button, no luck.
  //post.PostItems.Add("login_form", "input_go");
  
  // Here we set the method.
  post.Type = PostSubmitter.PostTypeEnum.Post;
  
  // Getting back the result.
  string result = post.Post();
  
  // Writting it to the file.
  TextWriter tw = new StreamWriter("C:/response.txt");
  tw.WriteLine(result);
  tw.Close();
  </code></pre>
  
  <p>The response.txt file has the same content as the login page, where it should have the code of the welcome page. Now how can I change code, to successfully login?</p>