cURL / Mailing Lists / curl-and-php / Single Mail

curl-and-php

noob - no idea!!!

From: Mark <mb97_at_bigfoot.com>
Date: Tue, 17 Aug 2004 22:34:41 +0100

Hi,

New here and to curl so please bear with me....

I'm trying to use curl to log in to www.racingpost.co.uk - a free site which requires registration then login to access their facilities so I'm registered with them.

I'm trying to use cURL to login and get the html of a certain page......keep getting 'restricted access - please log in' page.

cURL is enable on my php server....

here's my code:

<?php
$ch = curl_init("http://www.racingpost.co.uk");
echo "Setting cURL options...<br>";
$fp = fopen("aaa_example_races.txt", "w");
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_COOKIEJAR, "/tmp/cookie");
curl_setopt($ch, CURLOPT_COOKIEFILE, "/tmp/cookie");
$postfields = "in_un=rushtow&in_pw=mark1234&submit=submit&PARGS=pargs&in=in";
$postfields=urlencode($postfields);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postfields);
curl_setopt($ch, CURLOPT_URL, "http://www.racingpost.co.uk/horses/a_days_racing.sd?crs=YOR&r_date=2004-8-18&flag=1&cards=1");
curl_setopt($ch, CURLOPT_FILE, $fp);
curl_setopt($ch, CURLOPT_HEADER, 1);
echo "Executing cURL options...<br>";
curl_exec($ch);

curl_close($ch);
fclose($fp);
?>

here's the relevant html of the login frame - as far as I can tell.....

<TABLE cellSpacing=0 cellPadding=0 width=680 border=0>
  <FORM name=rpsign onsubmit="rp_sign(document.rpsign);return false"
  action=login_iframe.sd method=post>
  <TBODY>
  <TR vAlign=center bgColor=#d9d9d9 height=30>
    <TD align=middle width=50><IMG src="Login_files/top_username.gif"
      VALIGN="CENTER"></TD>
    <TD vAlign=center align=middle width=115><INPUT class=B10 maxLength=30
      size=14 value=rushtow name=in_un></TD>
      
    <TD vAlign=center align=middle width=50><IMG
      src="Login_files/top_password.gif"></TD>
      
    <TD vAlign=center align=middle width=115><INPUT class=B10 type=password
      maxLength=30 size=14 name=in_pw></TD>
      
    <TD align=middle width=69><INPUT onclick="rp_sign(document.rpsign);return false" type=image
      src="Login_files/log_in_b.gif" name=submit></TD>
      
    <TD align=middle width=67><A onclick="rp_register(document.rpsign);return false"
      href="https://reg.racingpost.co.uk/cde/login_iframe.sd#"><IMG src="Login_files/register_b.gif" border=0></A><INPUT type=hidden value=IN
      name=process><INPUT type=hidden name=PARGS></TD>
      
    <TD align=middle width=69><A onclick="rp_help(document.rpsign);return false"
      href="https://reg.racingpost.co.uk/cde/login_iframe.sd#"><IMG src="Login_files/help_b.gif" border=0 name=in></A></TD>
      
    <TD align=middle width=116><A onclick="rp_forgotten(document.rpsign);return false"
      href="https://reg.racingpost.co.uk/cde/login_iframe.sd#"><IMG src="Login_files/forgotten_password_b.gif" border=0 name=in></A></TD>
      
    <TD align=middle>&nbsp;</A></TD></TR></TBODY></TABLE></FORM></BODY></HTML>

any one help???
Received on 2004-08-18