liamthebof Posted June 22, 2009 Share Posted June 22, 2009 Hello, yet again. I am making another php script which requires a login to get the page a data I require. I have used cUrl before, but I still do not know very much. I used Live headers to get the required postfields but still no luck. $url = "http://xxxxxxx.net/index.php?action=login"; $post = "user=xxxx&passwrd=xxxx&cookieneverexp=on"; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_COOKIEJAR, 'cookie.txt'); //curl_setopt($ch, CURLOPT_HEADER, 1); //curl_setopt($ch, CURLOPT_VERBOSE, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $post); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $output = curl_exec($ch); curl_close($ch); echo $output; The output is the login page with nothing changed. Not logged in, no 'incorrect password'. Ect. Any ideas. No doubt there is a very easy solution. Another note, it is a SMF forum, if that makes a difference. Quote Link to comment https://forums.phpfreaks.com/topic/163265-solved-php-curl-nothing-happening/ Share on other sites More sharing options...
aggrav8d Posted June 22, 2009 Share Posted June 22, 2009 Check which page the index.php form redirects to on login. you might have to send your first curl request somewhere like login.php to get access and then send your "real" request to the page you actually want. Quote Link to comment https://forums.phpfreaks.com/topic/163265-solved-php-curl-nothing-happening/#findComment-861383 Share on other sites More sharing options...
liamthebof Posted June 22, 2009 Author Share Posted June 22, 2009 Its stays on index.php. On another note, I think this may be related. This is an example of the cookie received when using liveheaders. Cookie: PHPSESSID=5c8febe59114b15ee507b1e032958ec6; SMFCookie463=a%3A4%3A%7Bi%3A0%3Bs%3A2%3A%2243%22%3Bi%3A1%3Bs%3A40%3A%22b56f140351f568fd7894418dc6dab2b18fef755c%22%3Bi%3A2%3Bi%3A1434907814%3Bi%3A3%3Bi%3A1%3B%7D Furthermore, my cookie.txt file is not being edited. Quote Link to comment https://forums.phpfreaks.com/topic/163265-solved-php-curl-nothing-happening/#findComment-861399 Share on other sites More sharing options...
MadTechie Posted June 22, 2009 Share Posted June 22, 2009 I thought the login got posted to http://xxxxxxx.net/index.php?action=login2 on SMF forum Quote Link to comment https://forums.phpfreaks.com/topic/163265-solved-php-curl-nothing-happening/#findComment-861423 Share on other sites More sharing options...
liamthebof Posted June 22, 2009 Author Share Posted June 22, 2009 OK, the key was in the login2, thank-you very much. I am not sure why, as login displays a login form, but it works so thankyou. Quote Link to comment https://forums.phpfreaks.com/topic/163265-solved-php-curl-nothing-happening/#findComment-861445 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.