0

I'm using C# to log on a website. I have a helpful code sample for the C# bit, but it requires that I pass the PHP script the login parameters in a format similar to "username=myusername&password=mypassword". I don't know PHP nor do I have access to the script. Is there a way to deduce from the markup what parameters the script is expecting?

Here's the basis of my C# code: Login to website, via C#

Thanks in advance.

    <form id="login" method="post" action="http://mysite.com/forums/index.php?app=core&amp;module=global&amp;section=login&amp;do=process">
        <input type="hidden" value="990ea6a14ea49e853634fbdc5015a024" name="auth_key">

            <input type="hidden" value="http://www.mysite.com/" name="referer">

            <div id="regular_signin">
                <a id="_regularsignin"></a>
                <h3 class="bar">Enter your sign in name and password</h3>
                <ul>
                    <li class="field">
                        <label for="username">Username or email address:</label>
                        <input type="text" size="25" name="username" class="input_text" id="username">
                    </li>
                    <li class="field">
                        <label for="password">Password:</label>
                        <input type="password" size="25" name="password" class="input_text" id="password"><br>
                        <a title="Retrieve password" class="desc" href="http://mysite.com/forums/index.php?app=core&amp;module=global&amp;section=lostpass">I've forgotten my password</a>
                    </li>
                </ul>
</div><hr>
            <fieldset id="signin_options">
                <legend>Sign in options</legend>
                <ul>
                    <li class="field checkbox">
                        <input type="checkbox" class="input_check" value="1" name="rememberMe" checked="checked" id="remember">
                        <label for="remember">
                            Remember me<br>
                            <span class="desc">This is not recommended for shared computers</span>
                        </label>
                    </li>

                        <li class="field checkbox">
                            <input type="checkbox" class="input_check" value="1" name="anonymous" id="invisible">
                            <label for="invisible">
                                Sign in anonymously<br>
                                <span class="desc">Don't add me to the active users list</span>
                            </label>
                        </li>

                </ul>
            </fieldset>
            <fieldset class="submit">
                <input type="submit" value="Sign In" class="input_submit"> or <a class="cancel" title="Cancel" href="http://mysite.com/forums">Cancel</a>
            </fieldset>
        </form>
Community
  • 1
  • 1
0x1mason
  • 757
  • 8
  • 20
  • Well, the markup is incomplete, so it's possible that the script expects more than these variables: referer, username, password, auth_key. Please post the complete form markup. – arifwn Nov 16 '10 at 19:19
  • I'm more interested in learning to identify the patterns than in the specifics of this particular site. However, I've added all the markup for the form if that's helpful. Thanks for taking a look. – 0x1mason Nov 16 '10 at 19:38

1 Answers1

1

When the form is submitted, the end point (action) will receive each of the inputs by name in the $_POST array. In this case, the PHP script will likely be expecting $_POST['username'] and $_POST['password']. It will also get the contents of the hidden inputs and they too will appear in the $_POST super global.

Kevin Eaton
  • 100
  • 3
  • 13
  • If I follow you correctly, then the parameter the C# is passing will likely extend the format "username=myusername&password=mypassword" to include the hidden inputs. E.g., "auth_key=myauthkey&referer=myreferer&username=myusername&password=mypassword" – 0x1mason Nov 16 '10 at 19:27