Without using forms and hidden variables, how to send
variables from a PHP script to another URL using POST
method?

Answer Posted / lakhan lal

you can do it using curl

example:

<?
$URL="www.mysite.com/test.php";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,"https://$URL");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch,
CURLOPT_POSTFIELDS, "Data1=blah&Data2=blah");curl_exec
($ch);
curl_close ($ch);
?>

Is This Answer Correct ?    5 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is cookie and why do we use it?

516


Tell me how can we define a variable accessible in functions of a php script?

514


What is the meaning of "enctype= multipart/form-data" ?

519


What is meant by variable variables in php?

519


What is explode() in php?

531






Tell me what is the meaning of a final class and a final method?

513


What are the differences between mysqli_connect and mysqli_pconnect?

523


What are getters and setters php?

530


What is the use of imagetypes() method?

525


Tell me what type of operation is needed when passing values through a form or an url?

525


How to test if a variable is an array?

549


Do you know what is the function func_num_args() used for?

551


Name some of the constants in php and their purpose.

523


How can you upload a file using php?

538


What is php and features of php?

441