我有以前用来收集用户信息并存储在 .txt 文档中的 php 代码,但我已将其拉回,它似乎引发了我从主机客户那里得到的错误。
谁能告诉我怎么了?
谢谢
将代码编辑为我认为错误指向的内容
.php 文件 vv
<?php
if(isset($_POST['Name']) && isset($_POST['Email']) && isset($_POST['PNumber']) && isset($_POST['PostC']) {
$data = $_POST['Name'] . '-' . $_POST['Email'] . '-' . $_POST['PNumber'] . '-' .
$_POST['PostC'] . "\n";
$ret = file_put_contents('mydata.txt', $data, FILE_APPEND | LOCK_EX);
if($ret === false) {
die('There was an error writing this file');
}
else {
echo "$ret bytes written to file";
}
}
else {
die('no post data to process');
}
$location = "index.html";
header( "Location: $location" );
Html vvvv
<script>
$(function() {
$("#Subscribe").validate({
rules: {
Name: {
required: true,
minlength: 2,
maxlength: 23,
},
Email: {
required: true,
email: true
},
PNumber: {
required: false,
number: true
},
PostC: {
required: false,
}
}});
});
</script>
<form id="Subscribe" method="POST" action="subscribe.php">
<p class="subBox"><span>(Required) Name: </span><input id="Name" type="text" name="Name" size="20"></p>
<p class="subBox"><span>(Required) Email: </span><input id="Email" type="text" name="Email" size="20"></p>
<p><span>(Optional) Number: </span><input id="PNumber" type="text" name="PNumber" size="20"></p>
<p><span>(Optional) Postcode: </span><input "PostC" type="text" name="PostC" size="20"></p>
<p class="Submit"><span><input type="submit" value="Subscribe" name="Submit"></span></p>
</form>
它应该像以前一样将表单中输入的文本存储到 mydata.txt 文件中,但出现错误:
PHP 解析错误:语法错误,第 2 行中的(出于安全考虑而删除)/subscribe.php 中出现意外的“&&”(T_BOOLEAN_AND)
注意:我已经复制了以前工作过的内容,但这次我更改了选项
芜湖不芜
30秒到达战场