假设我有一个index.php:
<?php
$currentUser = "Paedow";
?>
我有一个user.php:
<?php
printf($_POST["currentUser"]);
?>
如何在调用时将变量提交$currentUser
给user.php ?
我试过这段代码,但这只会提交数据而不调用/查看页面:
function PostToHost($host, $path, $referer, $data_to_send) {
$fp = fsockopen($host, 80);
fputs($fp, "POST $path HTTP/1.1\r\n");
fputs($fp, "Host: $host\r\n");
fputs($fp, "Referer: $referer\r\n");
fputs($fp, "Content-type: application/x-www-form-urlencoded\r\n");
fputs($fp, "Content-length: ". strlen($data_to_send) ."\r\n");
fputs($fp, "Connection: close\r\n\r\n");
fputs($fp, $data_to_send);
while(!feof($fp)) {
$res .= fgets($fp, 128);
}
fclose($fp);
return $res;
}