文本字段数据未在表单POST方法中正确传递

时间:2015-03-31 18:07:45

标签: php html forms

我正在为我的公司使用HTML并使用PHP处理数字就业应用程序。

表单由以下内容定义:<form method="post" action="./php/post.php" name="empapp">,文字字段由以下内容定义:<input size="13" name="canyoufeelityeah">

我的PHP页面包含以下行: `print_r($ _POST);         print_r($ _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>";
    }`

所有$ _POST变量的打印显示变量“canyoufeelityeah”及其值,但这段代码总是拉空。

任何人都可以帮忙吗?我有大约30个其他变量正在通过,但这一个是唯一一个给我任何问题,我不知道为什么。

谢谢!

3 个答案:

答案 0 :(得分:0)

您在assignment声明中正在执行comparison而不是if

你写道: ($_POST["canyoufeelityeah"] = ' ')

它应该是: ($_POST["canyoufeelityeah"] == ' ')

答案 1 :(得分:0)

试试这个,我想你忘记了'=='

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>";
    }`

答案 2 :(得分:0)

试试这个。

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>";
    }