在后台将变量从PHP发送到任何绝对或相对页面?

在后台将变量从PHP发送到任何绝对或相对页面?,php,post,Php,Post,如何将它们发布到此处的任何页面,以及如何将这些变量同时发送到多个页面 //catched those variables within the same page $event = $_POST['event']; $when = $_POST['eventdate']; $where = $_POST['place']; $name = $_POST['name']; $tel = $_POST['tel']; $email = $_POST['email']; send $event, $w

如何将它们发布到此处的任何页面,以及如何将这些变量同时发送到多个页面

//catched those variables within the same page
$event = $_POST['event'];
$when = $_POST['eventdate'];
$where = $_POST['place'];
$name = $_POST['name'];
$tel = $_POST['tel'];
$email = $_POST['email'];
send $event, $when, $where, ... to("whateverurl1");//not the way

可以使用将数据发布到URL,这样就可以从PHP发送HTTP请求

在您的情况下,类似这样的事情可能会起到作用:

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://www.example.com/");
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, array(
    'event' => $event, 
    'when' => $when, 
    // ... more here
));
$returned = curl_exec($ch);
curl_close($ch);
有关更多信息,请参阅的手册页,有关更多选项(可能有很多选项!),请参阅


在这里,最重要的是:

  • CURLOPT_URL
    :指定要将数据发布到的URL
  • CURLOPT_POST
    :当您想要发送HTTP POST请求时——而不是GET,这是默认设置
  • CURLOPT_POSTFIELDS
    :指定要发送的数据


但请注意,这不会并行发送多个查询——也许其他
curl\u multi.*
函数可能会有所帮助,这里…

好,但我是否必须包含一些内容,因为:致命错误:调用未定义的函数curl\u init()哦,太不酷了:-(;;未定义该函数意味着服务器上未安装/启用curl扩展;-(;;如果在服务器上启用,解决方案可能是使用
fopen
+流上下文发送HTTP POST请求(请参见上的示例#1);否则,你必须去一个使用
fsockopen
的库中。好的,如果启用了,我想这是可行的,谢谢,还是我应该检查一下你的答案猜测?