Jump to content

Pastrare sesiuni active la trimiterea datelor cu cURL


Recommended Posts

Posted

Salut, vreau sa trimit date catre un formular cu cURL dar am o problema, ca sa accesez formularul trebuie sa fiu logat iar la trimiterea datelor imi arata ca sunt delogat, de ce? Si cum as putea pastra sesiunile active atunci cand trimit datele cu cURL?(https://imgur.com/a/iWtb3LJ)

Cod:

<?php
//receives string $html with html code
//returns the value of the html input with name of $name
function getInpValName($html, $name){
 .
 .
 .
}
 
//Test
$html = file_get_contents('http://localhost/whmcs/clientarea.php?action=changepw');


$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, "http://localhost/whmcs/clientarea.php?action=changepw");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, true);

// $str = substr(str_shuffle(str_repeat("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 5)), 0, 8);
$data = array(
	'token' => "". getInpValName($html, 'token') ."",
	'existingpw' => "Pass1*",
	'newPassword1' => "Pass2*",
	'newPassword2' => "Pass2*"
);

curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
$output = curl_exec($ch);
$info = curl_getinfo($ch);
curl_close($ch);

echo '<pre>';
print_r($data);
echo '<br />';

print_r($info);
echo '</pre>';
echo '<br />';
echo $output;
?>

 

  • Downvote 1

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • 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.