我正在为我的公司开发一个数字就业申请,使用HTML并使用PHP进行处理。
表单由:<form method="post" action="./php/post.php" name="empapp">
定义,文本字段由:<input size="13" name="canyoufeelityeah">
定义
我的PHP页面包含以下行:`print_r($_POST);print_r($_POST["canyoufeelityiah"]);
if (($_POST["canyoufeelityeah"] = ' ') or ($_POST["initials2"] = ' ') or ($_POST["initials3"] = ' ') or ($_POST["initials4"] = ' ') or ($_POST["signature"] = ' '))
{
echo $_POST["canyoufeelityeah"]."|".$_POST["initials2"]."|".$_POST["initials3"]."|".$_POST["initials4"]."|".$_POST["signature"]."|";
echo "You must initial each of the 4 blocks and sign your name at the bottom. <br />You will be redirected to your application in 15 seconds...";
// echo "<script>setTimeout('"window.history.back()'", 1500)</script>";
}`
打印所有$_POST变量时,会显示带有值的变量"canyoufeelityeah",但这段代码始终为空。
有人能帮忙吗?我还有大约30个其他变量正在传递,但这是唯一一个给我带来问题的变量,我不知道为什么。
谢谢!
试试这个。
if (empty($_POST["canyoufeelityeah"]) or empty($_POST["initials2"]) or empty($_POST["initials3"]) or empty($_POST["initials4"]) or empty($_POST["signature"]))
{
echo $_POST["canyoufeelityeah"]."|".$_POST["initials2"]."|".$_POST["initials3"]."|".$_POST["initials4"]."|".$_POST["signature"]."|";
echo "You must initial each of the 4 blocks and sign your name at the bottom. <br />You will be redirected to your application in 15 seconds...";
// echo "<script>setTimeout('"window.history.back()'", 1500)</script>";
}
您在if
语句中执行的是assignment
,而不是comparison
。
您写道:($_POST["canyoufeelityeah"] = ' ')
它应该是:($_POST["canyoufeelityeah"] == ' ')
试试这个,我想你忘记了'==='
if (($_POST["canyoufeelityeah"] == ' ') or ($_POST["initials2"] == ' ') or ($_POST["initials3"] == ' ') or ($_POST["initials4"] == ' ') or ($_POST["signature"] == ' '))
{
echo $_POST["canyoufeelityeah"]."|".$_POST["initials2"]."|".$_POST["initials3"]."|".$_POST["initials4"]."|".$_POST["signature"]."|";
echo "You must initial each of the 4 blocks and sign your name at the bottom. <br />You will be redirected to your application in 15 seconds...";
// echo "<script>setTimeout('"window.history.back()'", 1500)</script>";
}`