Okay, just to make this simpler here it my script:
<?php
$url = "http://www.wunderground.com/calculators/solar.html";
$useragent = 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1';
$referer ="http://www.google.com";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_FAILONERROR, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, "solar_lat=41.0877&solar_lon=-73.7768action=submit");
//"url=index%3Dbooks&field-keywords=PHP+MYSQL"
curl_setopt($ch,CURLOPT_USERAGENT,$useragent);
curl_setopt($ch,CURLOPT_REFERER,$referer);
$result = curl_exec($ch); // run the whole process
curl_close($ch);
$myFile = "testFile.html";
$fh = fopen($myFile, 'w') or die("can't open file");
fwrite($fh, $result);
fclose($fh);
I dropped the check box requirement for now. Here is the code on the page that contains the form. I simplified it somewhat.
<form name="solar_energy_lookup" action="solar.html" method="POST">
<input type="hidden" name="action" value="submit" />
<tr>
<td class="taR nobr b">Lat:</td>
<td><input type="text" class="inputText" id="solar_lat" name="solar_lat" value="" /><span class="b"> - Required</span></td>
</tr>
<tr>
<td class="taR nobr b">Lon:</td>
<td><input type="text" class="inputText" id="solar_lon" name="solar_lon" value="" /><span class="b"> - Required</span></td>
</tr>
<tr><td class="taR nobr b">Give raw insolation data:<br /></td>
<td class="taL"><input type="checkbox" id="insolation_only" name="insolation_only" onClick="check_insolation_only();" /><br />
(Check this box if you would like the amount
of energy per m<sup>2</sup> per day for your
location to do your own calculations.)</td></tr>
<a class="buttonO" id="solar_form_submit" onclick="submit_solar_form();">Submit</a></span>
</td>
</tr>
</form>
Can you tell me what I am doing wrong? When I open the saved page it just shows me the default page.
P.S. The information I am looking the get is from a government website that is public domain. The problem is the information is not in a readily usable format.