是的我相信我已经完成了,但我收到一条消息,说106线上的C:\ wamp \ www \ contactform.php中的解析错误:解析错误,意外$结束。在那条线上。唯一想到的是我能想到的是,else,如果是错误的,我一直在试图切换它们,看看是否会有所不同。但到目前为止还没有。在PHP中读取错误
</style>
</head>
<body>
<div id="container">
<?php
if (isset($_POST['submit'])){
if (trim($_POST['name'])==""){
$strMessage="Please enter your name!";
showForm($strMessage);
} elseif (isset($_POST['submit'])){
if (trim($_POST['email'])==""){
$strMessage="Please enter your email!";
showForm($strMessage);
}
if(isset($_POST['submit'])){
if (trim($_POST['username'])==""){
$strMessage="Please enter your username!";
showForm($strMessage);
} elseif ($_POST['pword1'] != $_POST['pword2']) {
$_POST['pword1'] = NULL; // Reset the values of pword1 so it is not in the form
$_POST['pword2'] = NULL; // Reset the values of pword2 so it is not in the form
$strMessage="Passwords do not match!";
showForm($strMessage);
} elseif (strlen(trim($_POST['pword1']))<=3){
$strMessage="Your password must be at least 4 characters long!";
showForm($strMessage);
} else {
$strMessage="Thank you, your information has been submitted. Below is the information you sent:";
$strMessageBody.="Name: ".trim(stripslashes($_POST['name']))."<br />";
$strMessageBody.="E-mail: ".trim(stripslashes($_POST['Email']))."<br />";
$strMessageBody.="UserName: ".trim(stripslashes($_POST['username']))."<br />";
$strMessageBody.="Password: ".trim(stripslashes($_POST['pword1']))."<br />";
$strMessageBody.="Re-enter Password: ".trim(stripslashes($_POST['pword2']))."<br />";
echo "<h1>".$strMessage."</h1>";
echo $strMessageBody;
}
} else {
$strMessage= "Please fill out the form below to send your information:";
showForm($strMessage);
}
}
?>
</div>
</body>
</html>
你应该学会更好的缩进。 (使用软标签进行缩进)很难读取您的代码。你可能在某处有一个缺失的大括号。正确缩进你的代码;它可以帮助团队环境中的其他开发人员,即使你是独自一人,它仍然会帮助你。 – FinalForm
您错过了一个右大括号。编程不是随机切换的。 – Jon
第87行的'else'前的'.'是什么? – rid