this is the remote form am try to login inside i'm trying to access website from script then i will get some data in out put But i stile not able to access something wrong please some one explain to me !!! <html> <body> <div id="all"> <div id="log-in"> <h2>Log In</h2> <form name='login' method='post' action='index.php' > <table cellspacing='2' width='300px'> <tr> <td align='left' colspan=3> </td> </tr> <tr> <td align='right' width=150> <input tabindex='1' type='hidden' name='type' value='auth' > User name </td> <td align='left'> <input tabindex='3' type='text' name='login_name' class='login' size='20' > </td> <td rowspan=2><input tabindex='2' type='submit' name='submit' value='Enter' ></td> </tr> <tr> <td align='right'> Password </td> <td align='left'> <input type='password' name='password' class='login' size='20' > </td> </tr> </table> </form> </div> </div> </body> </html> Code (markup): this is my script it load the page but no access <?php $post_fields = array('login_name' => $user, 'password' => $password,'cookieuser'=>"1" ); $url = "http://URL/index.php"; // Init curl $ch = curl_init(); // Set options curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $post_fields); curl_setopt($ch, CURLOPT_HEADER, false); curl_setopt($ch, CURLOPT_COOKIE, $cookie_name); curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_name); curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_name); curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']); // Execute request $result = curl_exec($ch); $cookie_name = tempnam("tmp", "g_".date(Y.m.d)); $user="myusername"; $password="mypassword"; $login = login($user,$password,$cookie_name); ?> Code (markup):
<?php function login($user,$password,$cookie_name){ $post_fields = "login_name=".urlencode($user); $post_fields .= "&password=".urlencode($password); $post_fields .= "&type=auth"; $url = "http://URL/index.php"; // Init curl $ch = curl_init(); // Set options curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $post_fields); curl_setopt($ch, CURLOPT_HEADER, false); curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_name); curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_name); curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']); // Execute request $result = curl_exec($ch); return $result; } $cookie_name = tempnam("tmp", "g_".date(Y.m.d)); $user="myusername"; $password="mypassword"; $login = login($user,$password,$cookie_name); print $login; ?> and don't forget to change http://URL/index.php to the real one