I am trying to get a few different element from the page at http://henrico.k12.va.us/GradesView.aspx but the website requires a login form and I when try to use file_get_contents it says object moved here with a link that just lead to my homepage after redirecting from a mixture of the site I'm trying to get to and my site. It would be great if someone knew how to fix this or if this is completely wrong could point me in the right direction. Thank you in advance. This is the code I have so far:
<?php
//create array of data to be posted
$post_data['Login1$UserName'] = 'hcps-******';
$post_data['Login1$Password'] = '*';
//traverse array and prepare data for posting (key1=value1)
foreach ( $post_data as $key => $value) {
$post_items[] = $key . '=' . $value;
}
//create the final string to be posted using implode()
$post_string = implode ('&', $post_items);
//create cURL connection
$curl_connection =
curl_init('https://hcpslink.henrico.k12.va.us/GradesView.aspx');
//set options
curl_setopt($curl_connection, CURLOPT_CONNECTTIMEOUT, 30);
curl_setopt($curl_connection, CURLOPT_USERAGENT,
"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)");
curl_setopt($curl_connection, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl_connection, CURLOPT_SSL_VERIFYPEER, false);
//set data to be posted
curl_setopt($curl_connection, CURLOPT_POSTFIELDS, $post_string);
//perform our request
$result = curl_exec($curl_connection);
$file = file_get_contents('https://hcpslink.henrico.k12.va.us/GradesView.aspx');
echo $file;
//show information regarding the request
print_r(curl_getinfo($curl_connection));
echo curl_errno($curl_connection) . '-' .
curl_error($curl_connection);
//close the connection
curl_close($curl_connection);
?>