Jump to content

POSTing data using PHP?


simonp

Recommended Posts

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.