我需要
的注册表格我做了第一个名字检查吗?
$errors = "";
if(!isset($_POST['First Name']))
$errors .= " Please provide a First Name.";
echo "reg done";
}else{
echo $errors. "enter your first name please";
答案 0 :(得分:1)
此表单仅检查_POST变量是否存在,而不是它是否有任何内容(无论是否将其留空都会将其解析为false。您也没有正确使用大括号(了解括号之间的区别)你想要的是:
$errors = "";
if(!isset($_POST['First Name']) || trim($_POST['First Name'])==""){
$errors .= " Please provide a First Name.";
echo "reg done";
} else {
echo $errors. "enter your first name please";
}
答案 1 :(得分:-1)
说真的,我可以建议在
上查看简单的PHP文档http://php.net/manual/en/language.basic-syntax.php
我认为你需要的不只是一个关于boggus问题的一点帮助,你的语法缺少一切能够成为好剧本的东西......
例如,您可以按照
的方式编写相同的代码if(!isset($_POST['FirstName'])){
$errors .= " Please provide a First Name.";
}
echo "reg done";
}else{ // <---------- you have an else here lying after some code and it doesn't seem to start anywhere...
echo $errors. "not done";
}