オンラインとオフラインで動作させたい HTML 上の単純なフォームがあります。データを CSV ファイルに投稿しようとしていますが、うまくいかないようです。
ここに私のHTMLコードがあります:
<form>
<label>Insert your name</label>
<input type="text" name="txtName" />
       
<input type="radio" name="choose" value="I agree with the terms and condtions">I agree with the terms and condtions
<input type="radio" name="choose1" value="I disagree with the terms and condtions">I disagree with the terms and condtions
<input type="submit" name="formSubmit" value="Submit" onclick="check()">
</p>
</form>
そして私のphp:
if($_POST['formSubmit'] == "Submit")
{
$errorMessage = "";
if(empty($_POST['txtName']))
{
$errorMessage .= "<li>Doh, You forgot to enter your name!</li>";
}
if(empty($_POST['choose']))
{
$errorMessage .= "<li>You must agree to the terms and conditions</li>";
}
if(empty($_POST['choose1'])
{
$errorMessage = "<li>You must agree to the terms and conditions</li>";
}
$varName = $_POST['txtName'];
$varChoose = $_POST['choose'];
$varChoose1= $_POST['choose1'];
$fs = fopen("stelios.csv","a");
fwrite($fs,$varName . ", " . $varChoose . "," . $varChoose1 . "\n");
fclose($fs);
header("Location: Test.html");
exit;
}
また、PHP はオフライン ストレージの良い方法ですか? FileSystemのことを考えていたのですが、IEしか対応していません。ありがとう