2010-11-16 17 views
0

我正在使用C#登錄網站。我爲C#位提供了有用的代碼示例,但它要求我以類似於「username = myusername & password = mypassword」的格式向PHP腳本傳遞登錄參數。我不知道PHP也不能訪問腳本。有沒有一種方法可以從標記中推斷腳本所期望的參數?如何推斷程序化POST的登錄PHP參數

這裏是我的C#代碼的基礎:Login to website, via C#

在此先感謝。

<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> 
+0

好吧,標記是不完整的,所以腳本可能期望超過這些變量:referer,username,password,auth_key。請發佈完整的表單標記。 – arifwn 2010-11-16 19:19:14

+0

我對識別模式比對這個特定站點的細節更感興趣。但是,如果有幫助,我已經爲表單添加了所有標記。謝謝參觀。 – 0x1mason 2010-11-16 19:38:41

回答

1

當提交表單時,終點(action)將通過$ _POST數組中的名稱接收每個輸入。在這種情況下,PHP腳本可能需要$ _POST ['username']和$ _POST ['password']。它也會得到隱藏輸入的內容,它們也會出現在$ _POST超級全局中。

+0

如果我正確地關注了你,那麼C#傳遞的參數可能會擴展格式「username = myusername&password = mypassword」以包含隱藏的輸入。例如,「auth_key = myauthkey&referer = myreferer&username = myusername&password = mypassword」 – 0x1mason 2010-11-16 19:27:25