-3
我想使用這個HTML表單從最終用戶收集信息並使用PHP將其保存到文本文件中。我正在尋找各種方式,我可以通過假設文本文件不存在以及如果文件存在時進行檢查和追加來完成此操作。有沒有人有什麼建議?如何使用php將html5格式的數據存儲到txt文件
HTML表單:
<form id="newuser" method="post" action="newUser.php">
<fieldset>
<label for="name">Name</label>
<input type="text" name="name" placeholder="Full Name">
<label for="email">E-mail</label>
<input type="email" name="email" placeholder="[email protected]">
<label for="birthday">Birthday</label>
<input type="date" name="birthday" min="1929-12-31">
<label for="phone">Phone</label>
<input type="tel" name="phone" placeholder="ex. (555) 555-5555">
<label for="message">Question/Comment</label>
<textarea name="message"></textarea>
<label>Check this box if you agree to the website
<a href="terms.php">terms</a>
<input type="checkbox" name="agreetoterms" value="Agree"> </label>
<input type="submit" name="submit" id="submit" value="Join Now" />
</fieldset> </form>
在'newuser.php' - 'file_put_contents( 'C:/temp/form.txt' 的print_r($ _ POST,真),FILE_APPEND);' ?? – RamRaider
請在這裏閱讀關於[問]的問題。你應該顯示你的嘗試。我們將幫助您修復代碼,但我們不是代碼編寫服務。 –
@RamRaider你可以進一步闡述爲什麼我在「newser.php」中做這個改變嗎?我不太明白那行代碼在做什麼。這就是爲什麼輸入不顯示?如果是這樣,它不應該指向「storeFormData.txt」嗎? – Chris