php在重定向后从隐藏字段中获取值

时间:2015-04-09 15:24:34

标签: php

  • member.php

    <?php
        if(isset($_POST['submit']))
        {
            $membername = $_POST['membername'];
    
            if(empty($membername))
            {
                $errors .= "Please enter member name<br />";
            }
    
            if($errors)
            {
                $action = $_POST['submit'];
                echo $errors;
                displayForm();
            }
            else
            {
    ?>
                <input type="hidden" name="mname" value="<?php echo $_POST['membername']; ?>" />
    <?php
                $action = $_POST['submit'];
                header("Location: commit.php?action=$action");
                exit();
            }
        }
        else
        {
            displayForm();
        }
    ?>
    
    <?php
    function displayForm()
    {
    ?>
        <form action = "member.php" action="post">
            Member Name <input type="text" name="membername" value="<?php if(isset($row['name'])) echo $row['name']; 
            else echo ''; ?>" /><br /><input type="text" name="membername" value=
            <input type="submit" name="submit" name="add" />
        </form>
    <?php
    }
    ?>
    
  • Commit.php

    <?php
        echo $_POST['mname']; //HERE
    ?>
    
  • 我想传递member.php中的隐藏值。当我运行commmit.php时,我想得到隐藏的字段值。但是,错误如下: **未定义的索引:commit.php中member.php中的mname。

  • 我做错了什么?

0 个答案:

没有答案