我是使用cURL的新手,所以我需要您的帮助。我的情况是,我想通过form-site(form.php)发送一个form(formular.php)。php curl不发送表单中的发布数据
form.php通过cURL调用formular.php。
这里都是源代码:
form.php的
<?php
error_reporting(-1);
$url = 'http://localhost/formular.php';
$data = array('customerline' => 'nummer1', 'customerphonenumber' => 'nummer2');
$postString = http_build_query($data, '', '&');
$ch = curl_init();
curl_setopt ($ch, CURLOPT_URL, $url);
curl_setopt ($ch, CURLOPT_POST, 2);
curl_setopt ($ch, CURLOPT_POSTFIELDS, $postString);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
$post = curl_exec ($ch);
curl_close ($ch);
echo $post;
?>
formular.php
<?php if(isset($_POST['form'])): ?>
Sent!
<?php else: ?>
<form action="http://localhost/formular.php" method="post" name="form">
<input type="text" name="customerline" />
<input type="text" name="customerphonenumber" />
<input type="submit" value="send" name="form" />
</form>
<?php endif; ?>
我的问题是,我不知道如何获得文字段落“发送!”。
你能帮我吗?
感谢您的输入,现在它的工作,完美!举手 (: –