php 代码从表单中获取值并将其写入平面文件。这段代码在本地工作,但是当我把它放在主机上时,我得到了两个错误。本地实例不需要目录中的 config.php,但主机文件需要。
error1:声明没有config.php
错误2:我必须指定一个路径,但如果
? - 我在配置文件中放了什么,所以它允许我创建平面文件,或者我可以引用相同的文件吗?
任何帮助,将不胜感激。
代码:
<html>
<head>
<title>test</title>
</head>
<body>
<?php
include('config.php');
$user = $_GET["name"];
$message = $_GET["message"];
print("<b>Thank You!</b><br />Your information has been added! You can see it by <a href=savedinfo.php>Clicking Here</a>");
$out = fopen( $_SERVER['DOCUMENT_ROOT'] . '/flatfile/test/' . $user . '.txt', "a" );
if (!$out) {
print("Could not append to file");
exit;
}
fputs ($out,implode,("\n"));
fwrite($out,"<b>$user</b><br />$message<br /><br />");
fclose($out);
?>
</body>
</html>
错误:
1
Warning: include(config.php) [function.include]: failed to open stream: No such file or directory in /home/user1/flatfile/sendinfo.php on line 7
2
Warning: include() [function.include]: Failed opening 'config.php' for inclusion (include_path='.:/usr/local/lib/php:/usr/local/php5/lib/pear') in /home/user1/flatfile/sendinfo.php on line 7