matthewlesh Posted September 22, 2007 Share Posted September 22, 2007 Hey there everyone.. This is something which i have wanted to be able to do for ages, Well anyway what i would like this script to do is : 1. Login Using POST to an SSL Server (The login system uses cookies) 3. Go to a page after login and get the information into a variable Any help with this would be very great. Quote Link to comment https://forums.phpfreaks.com/topic/70253-php-script-to-login-to-external-web-pages/ Share on other sites More sharing options...
BlueSkyIS Posted September 22, 2007 Share Posted September 22, 2007 look into the curl functions Quote Link to comment https://forums.phpfreaks.com/topic/70253-php-script-to-login-to-external-web-pages/#findComment-352850 Share on other sites More sharing options...
rarebit Posted September 22, 2007 Share Posted September 22, 2007 What CMS are you using? Quote Link to comment https://forums.phpfreaks.com/topic/70253-php-script-to-login-to-external-web-pages/#findComment-352881 Share on other sites More sharing options...
matthewlesh Posted September 24, 2007 Author Share Posted September 24, 2007 look into the curl functions OK, I've had a look around a bit... but now i have come into another problem... I don't know how to use curl and there doesn't seem to be much around about it. What i need to do now it work out how to : 1. Go to a page and pick up some cookies 2. Send post information to another page with those cookies being sent 3. Set more cookies after that form has been sent 4. View a page with the cookies being sent I have had a look at a few page and found out how to just do the post part.. but everything else i am extremely confused about: define('POSTURL', '<website to send post>'); define('POSTVARS', 'send=yes&q=$data'); // POST VARIABLES TO BE SENT // INITIALIZE ALL VARS $Email=''; $ch=''; $Rec_Data=''; $Temp_Output=''; if($_SERVER['REQUEST_METHOD']==='POST') { // REQUIRE POST OR DIE $ch = curl_init(POSTURL); curl_setopt($ch, CURLOPT_POST ,1); curl_setopt($ch, CURLOPT_POSTFIELDS ,POSTVARS); curl_setopt($ch, CURLOPT_FOLLOWLOCATION ,1); curl_setopt($ch, CURLOPT_HEADER ,0); // DO NOT RETURN HTTP HEADERS curl_setopt($ch, CURLOPT_RETURNTRANSFER ,1); // RETURN THE CONTENTS OF THE CALL $Rec_Data = curl_exec($ch); ob_start(); header("Content-Type: text/html"); $Temp_Output = ltrim(rtrim(trim(strip_tags(trim(preg_replace ( "/\s\s+/" , " " , html_entity_decode($Rec_Data)))),"\n\t\r\h\v\0 ")), "%20"); $Temp_Output = ereg_replace (' +', ' ', trim($Temp_Output)); $Temp_Output = ereg_replace("[\r\t\n]","",$Temp_Output); $Temp_Output = substr($Temp_Output,307,200); echo $Temp_Output; $Final_Out=ob_get_clean(); echo $Final_Out; curl_close($ch); } else die('Hacking attempt Logged!'); exit; Quote Link to comment https://forums.phpfreaks.com/topic/70253-php-script-to-login-to-external-web-pages/#findComment-353816 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.