Curl redirect problem

Hello there,
Its been a long while since i posted on this forum although ive been learning a lot just by reading other posts here. Now I have problem with using cURL and ive searched everywhere else and am still stuck. Sitepoint is where it all began for me so it seems natural that i should find the answers here. so here goes:

Im using curl to retrieve info that is behind a password protected page on another site. I POST the username and password using curl which has worked well on previous projects. I also noticed the site has multiple redirects so ive rewritten my script several times to handle. After all my attempts, i still get the login screen as the data retrieved.

The Headers returned show that it is sent as GET instead of POST and the Host is my domain instead of the domain of the site am trying to connect to. I think this is the reason why I see a lot of HTTP/1.1 404 instead of 302, 301 or 304.

How do I solve the problem mentioned and still get curl to follow through to the password protected page?

Here is a sample of the headers sent when the script was running and for the calling page, it starts like this:

GET /cscs/cron/cscs_get_revised.php HTTP/1.1
Cache-Control: max-age=0

HTTP/1.1 200 OK
Date: Thu, 24 Mar 2011 08:27:48 GMT
Server: Apache mod_fcgid/2.3.6 

and the rest of the header info all start like this

GET /homeAd-portlet/css/test.css?t=1300726124431 HTTP/1.1
Cache-Control: max-age=0

HTTP/1.1 404 Not Found
Date: Thu, 24 Mar 2011 08:27:51 GMT
Server: Apache mod_fcgid/2.3.6 

here is a sample of my code:

    $url = str_replace( "&", "&", urldecode(trim($url)) );
	$headers = $url;

    $cookie = tempnam ("/tmp", "CURLCOOKIE");
    $ch = curl_init();
    curl_setopt( $ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; rv:1.7.3) Gecko/20041001 Firefox/0.10.1" );
    curl_setopt( $ch, CURLOPT_URL, $url );
    curl_setopt( $ch, CURLOPT_COOKIEJAR, $cookie );
    curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, true );
    curl_setopt( $ch, CURLOPT_ENCODING, "" );
    curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
    curl_setopt( $ch, CURLOPT_AUTOREFERER, true );
    curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, false );    # required for https urls
    curl_setopt( $ch, CURLOPT_CONNECTTIMEOUT, $timeout );
    curl_setopt( $ch, CURLOPT_TIMEOUT, $timeout );
    curl_setopt( $ch, CURLOPT_MAXREDIRS, 10 );
    curl_setopt( $ch, CURLOPT_UNRESTRICTED_AUTH, true);
		curl_setopt($ch, CURLOPT_POST, true);
		curl_setopt($ch, CURLOPT_POSTFIELDS, $authlogin); 
    $content = curl_exec( $ch );
    $response = curl_getinfo( $ch );
    curl_close ( $ch );

Please help, anyone. Thanks.