simonp Posted December 2, 2008 Share Posted December 2, 2008 Hi, I need to 'log people in' using php code - ie using a form I would do: <form name="login" action="https://www.xxx.com/login.php?goto=clientarea" method="POST" target="_blank"> <input type="hidden" name="username" size="20"> <input type="hidden" name="password" size="20"> </form> . . . but I need to be able to automatically submit that information from within php - does that make sense? Any tips on how to do that? I thought I might need cURL but not sure if that's right. Cheers Simon Link to comment https://forums.phpfreaks.com/topic/135149-posting-data-using-php/ Share on other sites More sharing options...
trq Posted December 2, 2008 Share Posted December 2, 2008 curl is indeed what your looking for. Link to comment https://forums.phpfreaks.com/topic/135149-posting-data-using-php/#findComment-703905 Share on other sites More sharing options...
simonp Posted December 2, 2008 Author Share Posted December 2, 2008 curl is indeed what your looking for. Thanks thorpe - I've done some googling and come up with: $ch = curl_init(); curl_setopt($ch, CURLOPT_URL,"https://www.xxx.com/login.php?goto=clientarea"); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, "username=$username&password=$password"); curl_exec ($ch); curl_close ($ch); . . . but I just end up with a blank page where as I need it to go to the logged in page (which is what I thought the followlocation line did). Any ideas? Cheers Simon Link to comment https://forums.phpfreaks.com/topic/135149-posting-data-using-php/#findComment-703935 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.