I have php code I have used previously to collect information from users and store in a .txt document but I have pulled it back it seems to throw an error I got from my host customer sup.
Can anyone tell me whats wrong?
Thanks
Editing the code to what I thought the error was pointing to
The .php File 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" );
The 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>
It should store the text entered in the form to a mydata.txt file like previously but is giving the error :
PHP Parse error: syntax error, unexpected '&&' (T_BOOLEAN_AND) in (Removed for security)/subscribe.php on line 2
Note: I have replicated what was previously working before but this time i have changed the options