我看到了这个问题,我想在评论中提出一个问题,但没有足够的声誉.所以我在这里问这个问题.
我有一个HTML格式的表单:
<form action="myprocessingscript.php" method="POST">
Name : <input name="field1" type="text" />
Email : <input name="field2" type="text" />
<input type="submit" name="submit" value="Save Data">
Run Code Online (Sandbox Code Playgroud)
和PHP中的处理脚本myprocessingscript.php
:
if (isset($_POST['field1']) && isset($_POST['field2'])) {
$data = 'comments.txt' . $_POST['field1'] . ' ' . $_POST['field2'] . "\n";
$ret = file_put_contents('comments.txt', $data);
if ($ret === false) {
die('There was an error Sending The Comment');
}
else {
echo "The Comment Has Been Sent Succesfully !";
}
}
else {
die('Fill in The Form Please …
Run Code Online (Sandbox Code Playgroud)