0

I have to login on page automatically using c#, for example I have on server side index.php which looks like this:

<?php
if($_POST['pass'] == "pass123")
    echo "Logged";
else
    echo "Failed";
?>

Form look like this:

<div align="center">
<form action="index.php" method="post">
<table width="380" style="margin-top:50px">
<tr>
    <td height="40" align="center">
        <fieldset><legend>Form Login</legend><br>
        <input type="password" name="pass" value="" size="20">
        <input type="submit" value="Login"><br><br>
        </fieldset>
    </td>
</tr>
</table>
</form>
</div>

And my question is how to start build c# app which should insert password in input pass, press submit and let me ktow there is Logged or Failed.

I was search it, but always is with using set "word" and click button with events, i don't want gui and download source code of page.

Regards

Tagon
  • 85
  • 13

1 Answers1

1

If you don't want a GUI and you don't want to download the pages source, the only other way I can see is to directly send a POST to the php file through the WebClient class, outlined in this Stack Overflow question.

var url = "test.php";
using (var wb = new WebClient())
{
    var data = new NameValueCollection();
    data["pass"] = "pass123";
    var response = wb.UploadValues(url, "POST", data);
}
Community
  • 1
  • 1
James Hunt
  • 2,448
  • 11
  • 23