【发布时间】:2012-01-06 16:50:06
【问题描述】:
我正在尝试使用 html 和 php 构建联系表单,但我收到了一个消息解析错误:,语法错误,第 81 行 c:\xampp\htdocs\myfolder\form_process.php 中的意外 T_ELSE,我真的这样做了不知道我哪里做错了,这是我下面的代码
<?php
session_start();
if($_POST['submit'])
{
$num = 0;
if(strlen($_POST['name']) > 0)
$num = $num;
$_SESSION['name'] = $_POST['name'];
unset($_SESSION['error_name']);
}
else
{
$num = $num + 1;
$_SESSION['error_name'] = "You have not filled out a Name";
}
if(strlen($_POST['surname']) > 0){
$num = $num;
$_SESSION['surname'] = $_POST['surname'];
unset($_SESSION['error_surname']);
}
else
{
$num = $num + 1;
$_SESSION['error_surname'] = "You have not filled out a Surname";
}
if(strlen($_POST['phone']) > 0){
$num = $num;
$_SESSION['phone'] = $_POST['phone'];
unset($_SESSION['error_phone']);
}
else
{
$num = $num + 1;
$_SESSION['error_phone'] = "You have not filled out a Phone Number";
}
if(strlen($_POST['email']) > 0){
$num = $num;
$_SESSION['email'] = $_POST['email'];
unset($_SESSION['error_email']);
}
else
{
$num = $num + 1;
$_SESSION['error_email'] = "You have not filled out a Email Address";
}
if(strlen($_POST['comments']) > 0){
$num = $num;
$_SESSION['comments'] = $_POST['comments'];
unset($_SESSION['error_comments']);
}
else
{
$num = $num + 1;
$_SESSION['error_comments'] = "You have not filled out a Comment";
}
if ($num == 0)
{
//process form
echo "success";
}
else
{
header("Location: inter.php");
}
else{
header("location: inter.php");
}
?>
有人帮忙
【问题讨论】:
-
如果你正确缩进你的代码,你会立即看到这种错误。
-
这个问题似乎是题外话,因为它是关于调试代码的。