使用cURL link extern传递$ _POST值

时间:2016-02-14 16:20:03

标签: php variables undefined notice

/www/formulair.php的代码:

<html>
<head>
</head>
<body>
<form action="recive.php" method="POST">
<input type="text" name="name"/>
<input type="submit" value="Send me your name!">
</form>
</body>
</html>

/www/recive.php的代码:

<?php
include ("config.php");
?>

/www/config.php的代码:

<?php 
$ch=curl_init();
curl_setopt($ch,CURLOPT_URL,'http://localhost/test.php');
curl_setopt ($ch, CURLOPT_POST, 1);
curl_setopt ($ch, CURLOPT_POSTFIELDS, $_POST['name']);
curl_exec($ch);
curl_close($ch);
?>

test.php的代码:

<?php
if(isset($_POST['name'])) {
    $fp = fopen('data.txt', 'a+');
    fwrite($fp,$_POST['name']);
    fclose($fp);
}
?>

错误:

  

Erreur:注意:未定义的变量

我应该在test.php写些什么来获取$_POST['name']

0 个答案:

没有答案