我有一個網站,我有兩個文本框用於輸入信息。我的「提交」按鈕命令一個PHP文件將兩個文本框中的信息複製/粘貼到名爲「Members.txt」的文本文件中。目的是從文本框中獲取信息並創建郵件列表。現在我的問題是我知道PHP文件正在調用文本文件,因爲每次點擊提交時,我都可以在我的ftp上看到文本文件已被編輯,同時我嘗試提交以作爲列表的一部分。另外,文本文件試圖將信息放入文本文件中,因爲我可以看到每次點擊「提交」按鈕時,文本文件輸入行越來越低。換句話說,輸入完整的一行。但沒有文字。不,文字不是白色的。我究竟做錯了什麼?創建郵件列表(PHP)
<h2>Join our Mailing List</h2>
<form method="post" action="add.php" name="signup">
<input type="hidden" name="pommo_signup" value="true" />
<table border="0" bordercolor="#000000"
bordercolordark="#000000" bordercolorlight="#000000">
<tr>
<td width="203" bgcolor="#FFFFFF"> </td>
</tr>
<tr>
<td bgcolor="#FFFFFF"> NAME: <font size="4">
<input name="name"
type="text" size="20" maxlength="100" />
</font></td>
</tr>
<tr>
<td height="26" bgcolor="#FFFFFF"> EMAIL: <font size="4">
<input name="email"
type="text" size="20" maxlength="100" />
</font></td>
</tr>
<tr>
<td height="31" bgcolor="#FFFFFF"><span style="text-align: left"></span><p align="middle">
<input type="image" src="ok.jpg" />
</p></td>
</tr>
</table>
</form>
THEN BELOW IS THE FORM THAT IS SUPPOSED TO ADD TO THE TEXT BOX.
<?php
$filename = "members.txt";
$fd = fopen ($filename, "r");
$contents = fread ($fd, filesize ($filename));
fclose ($fd);
if(strstr($contents,$email)) {
print "You're already subscribed to this mailing list.";
}
else {
echo "Thank you $email for joining the mailing list";
if (!$save = fopen("members.txt","a")) {
exit;
}
fwrite($save,"$email\r\n");
fclose($save);
if (!$save = fopen("names.txt","a")) {
exit;
}
fwrite($save,"$name\r\n");
fclose($save);
mail("$email", "Fairview HiFi News Letter", "Welcome to the Fairview HiFi mailing list. Your exclusive source for product and promotional news and events.",
"From: [email protected]\r\n"
."Reply-To: [email protected]\r\n"
."X-Mailer: PHP/" . phpversion());
}
?>
歡迎來到StackOverflow,@Matt! – Sampson 2010-01-28 16:59:46
請查看http://www.phplist.com/以獲得可供使用的郵件列表應用程序,作爲自己滾動的替代方案 – Gordon 2010-01-28 18:22:36