PHP读取错误
是的,我相信我已经完成了此操作,但我收到一条消息,上面写着“解析错误:解析错误,第 106 行 C:\wamp\www\contactform.php 中意外的 $end”。我俯视该行。唯一的想法我能想到的是,else、elseif 和 if 是错误的,我一直在尝试将它们互换,看看是否会有所不同。但到目前为止还没有任何进展。
</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>
Yes I believe I have this done but I am getting a message that is saying Parse error: parse error, unexpected $end in C:\wamp\www\contactform.php on line 106. I look down on that line.The only think I can think of is that the else, elseif and if are wrong i been trying to switch them around to see if that makes a different. But nothing so far.
</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>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我相信这就是你想要的。您已经重复“if (isset($_POST['submit'])){”两次太多了!
I believe this is what you want. You have been repeating the "if (isset($_POST['submit'])){" two times too many!
缺少一个结尾}。唯一的问题是在哪里?如果你把它放在前面?>解析错误将会消失,但我不确定这是一个合适的地方。取决于你的困难逻辑。
one closing } is missing. the only question is where? if you put it before ?> the parse error will disappear, but i'm not sure this is apropieate place. depends on your difficult logic.