function login_board($url,$ch)
{
$cookie="cookie.txt";
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_SSL_VERIFYHOST, false);
curl_setopt ($ch, CURLOPT_POSTFIELDS, 'user_id=myid&password=mypass&action
=login');
curl_setopt ($ch, CURLOPT_POST, 1);
echo $content = curl_exec( $ch );
}
The following approach doesn't log me into the site. If I run this twice consecutively, it just shows me the login page again instead of showing me the welcome screen.
If I try to access a page inside, it gives me a bad request.