我在我的網站上有這個部分,號召性用語是:“訂閱我的郵件列表,以便通知我的完整網站何時發布。如何收集電子郵件地址并將其保存到文件中(我猜它需要某種php或其他服務器端語言)代碼如下<div class="right"> <p class='attention'>Website to be released <br>early-mid 2020!</p> <form action="mailto" method="post" enctype="text/plain"> <input type="text" name='email' id='email' placeholder="your email"> <button type="submit">Notify Me</button> </form> </div>
1 回答

米脂
TA貢獻1836條經驗 獲得超3個贊
這是非常特定于您的要求,它將幫助您將電子郵件ID保存到項目目錄中的文件“data.txt”。
<!DOCTYPE html>
<html>
<head>
<title>Store form data in .txt file</title>
</head>
<body>
<div class="right">
<p class='attention'>Website to be released <br>early-mid 2020!</p>
<form method="post">
<input type="text" name='email' id='email' placeholder="your email">
<button type="submit" name="submit">Notify Me</button>
</form>
</div>
</body>
</html>
<?php
if(isset($_POST['submit']))
{
$data=$_POST['email']. PHP_EOL;
$fp = fopen('data.txt', 'a');
fwrite($fp, $data);
fclose($fp);
}
?>
- 1 回答
- 0 關注
- 90 瀏覽
添加回答
舉報
0/150
提交
取消