我正在尝试查看我的网页。但是,我不能,因为它显示“解析错误:语法错误,文件意外结束”
我一直在寻找任何拼写错误或错误,但我认为这还可以。不太确定还能尝试
<html>
<head>
<title>Form Elements</title>
</head>
<body>
<!-- this will have the form direct to form.php after pressing submit-->
<form action="form.php" method="post" id="myForm">
<?php
if(($_POST['fname'] == NULL) && ($_SERVER['REQUEST_METHOD'] == 'POST')){
echo "<strong>Please fill in your first name!</strong><br />";
}
?>
<!-- this label will have you type your first name and below that will be
your last name-->
<!-- the value php makes it so the first name is sticky and doesnt reset
when the user presses submit -->
<label for="1st">First Name:</label> <input type="text" name="fname"
value="<?php echo $_POST['fname']; ?>"id="1st"/><br />
<?php
#this does the exact same thing as NULL, this lets the user know to fill
out their first name
if(($_POST['lname'] == NULL) && ($_SERVER['REQUEST_METHOD'] == 'POST')){
echo "<strong>Please fill in your last name!</strong><br />";
}
?>
<label for="last">Last Name:</label> <input type="text" size="30"
name="lname" value="<?php echo $_POST['lname']; ?>" id="last"/><br />
<!-- this gives the user an option to have them send email updates to them
or not, it will be automatically checked-->
Sign up for email updates: <input type="checkbox" checked="checked"/><br />
<!-- this gives the user an option to check if they are male or female-->
Sex: male <input type="radio" name="sex"/> | female <input type="radio"
name="sex"/><br />
<!-- this drop down menu lets to user choose what size shirt they are-->
Select Shirt Size: <select name="size">
<option>small</option>
<option>medium</option>
<option>large</option>
<option>extra large</option>
</select>
<p>
<!-- this lets the user type in a password, it will automatically be so you
can't see it-->
create password: <input type="password" size="8" maxlength="4"/>
</p>
<!-- this lets the user tell us comments-->
<textarea rows="10" cols="40"> </textarea><br />
<!-- this lets the user either reset the form, or submit it-->
<?php
if(($_POST['agree'] == NULL) && ($_SERVER['REQUEST_METHOD'] == 'POST')){
echo "<strong>Please agree to our terms!</strong><br />";
?>
Please type: "yes" if you agree to our terms <input type="text"
name="agree" value="<?php echo $_POST['agree']; ?>"/>
<br />
<input type="reset" /> <input type="submit" value="Submit" />
</form>
<br />
<br />
<?php
$fname = $_POST['fname'];
$lname = $_POST['lname'];
#request and post can be used interchangeably assuming your form is set to
post
#this will hide the thank you message until the user fills out both first
name and last name
if (($_SERVER['REQUEST_METHOD'] == 'POST') && ($_POST['fname'] != NULL) &&
($_POST['lname'] != NULL)) {
echo "Thank you for your submission $fname $lname. Unfortunetly, we
cannot accept your submission as you do not agree to our terms.";
}
#this will check if they agree to our terms
if(($_SERVER['REQUEST_METHOD'] == 'POST') && ($_POST['fname'] != NULL) &&
($_POST['lname'] != NULL) && ($_POST['agree'] == "yes")) {
echo "Thank you for your submission $fname $lname.";
}
?>
我希望一切正常。我添加了评论以澄清。我希望姓氏和名字保持粘性,因此即使用户按了提交,并且他们还没有填写完他们的名字和姓氏仍在填写的表格。我希望用户输入“是”,然后输入,这表示他们同意这些条款。