Follow Our FB Page << CircleMedia.in >> for Daily Laughter. We Post Funny, Viral, Comedy Videos, Memes, Vines...

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

How long should a session last?

185


Write a php function to convert all null values to blank?

208


What is difference between session and cookies in php?

164


Suppose we receive a form submitted by a post to subscribe to a newsletter. This form has only one field, an input text field named email. How would we validate whether the field is empty? Print a message "the email cannot be empty" in this case?

179


What is substr() in php? And how it is used?

192






Why does sql injection happen?

198


Tell me when a conditional statement is ended with an endif?

186


What is isset in php?

181


What is a namespace in php?

153


Explain about PHP filter and why it should be used?

227


What are the array functions in php?

192


What are the Formatting and Printing Strings available in PHP?

235


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

190


Is php class name case sensitive?

173


Is age interval or ordinal data?

171