POST Request with php
<p>I'm a beginner in php programming and i search to retrieve a result of a selection in a dynamic web page.
This web page is <a href="http://forzamotorsport.net/en-US/community/leaderboard.aspx" rel="nofollow">http://forzamotorsport.net/en-US/community/leaderboard.aspx</a>.</p>

<p>For access on this webpage, you must be logged with hotmail account.
After that you can choose some categories.
The result is the array in bottom of the webpage.</p>

<p>My goal is to retrieve this array with all results.
The result can be put in a file, is not a problem for the further.</p>

<p>I have began with this:</p>

<pre><code>&lt;?php
$url = "http://forzamotorsport.net/en-US/community/leaderboard.aspx/GetRows";
$fields = array(
            'firstFilter'=&gt;urlencode('0'),
            'secondFilter'=&gt;urlencode('0'),
            'thirdFilter'=&gt;urlencode('147'),
            'fourthFilter'=&gt;urlencode('-1'),
            'sortView'=&gt;urlencode('0'),
            'rowsShown'=&gt;urlencode('10'),
            'startIndex'=&gt;urlencode('0')
        );

//url-ify the data for the POST
foreach($fields as $key=&gt;$value) { $fields_string .= $key.'='.$value.'&amp;'; }
rtrim($fields_string,'&amp;');

//open connection
$ch = curl_init();

//set the url, number of POST vars, POST data
curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch,CURLOPT_POST,count($fields));
curl_setopt($ch,CURLOPT_POSTFIELDS,$fields_string);

//execute post
$result = curl_exec($ch);
print $result;
?&gt;
</code></pre>

<p>And the result is that i arrive on the home page of this web site but i'm not logged.</p>

<p>Can you help me ?</p>

<p>Thanks a lot
David.</p>

<p>(Sorry for my bad english)</p>
