PHP在页面之间传递变量

时间:2015-10-14 17:38:02

标签: php variables

我在Joomla中遇到一段代码问题。它可能与启用PHP的插件有关,但万一它不是。

第1页有一个表格

<form action="/index.php/bridge" method="POST" name="postcode">
<div><input style="height: 50px;" type="text" placeholder="Enter Your Postcode..." /> <input type="submit" value="Get Started today!" /></div></form>

您输入的文字将成为我想传递的变量

第2页

<?php echo "test";

 $postcode=1;
$poster=$_POST['postcode'];
echo $poster;
// You can place PHP like this

?>

不幸的是,邮政编码没有回显

3 个答案:

答案 0 :(得分:1)

假设没有其他因素导致此错误,请尝试将您发送的输入命名为postcode

<form action="/index.php/bridge" method="POST">
    <div>
        <input style="height: 50px;"  name="postcode" type="text" "placeholder="Enter Your Postcode..." /> 
        <input type="submit" value="Get Started today!" />
     </div>
</form>

答案 1 :(得分:0)

在您的PHP代码中,您回显$_POST['postcode'],但在输入表单时,您不会在表单提交时发送相同的变量。

<form action="/index.php/bridge" method="POST" name="demoForm">
    <div>
        <input style="height: 50px;"  name="postcode" type="text" "placeholder="Enter Your Postcode..." /> 
        <input type="submit" value="Get Started today!" />
     </div>
</form>

答案 2 :(得分:0)

试试这个

jspm: {
       ...
        paths: {
            "github:*": "app/jspm_packages/github/*",
            "npm:*": "app/jspm_packages/npm/*",
            'app/*': 'app/*.js'
        },

        ...
    },

<form action="/index.php/bridge" method="POST">
<div>
    <input name="postcode" style="height: 50px;" type="text" placeholder="Enter Your Postcode..." />
    <input type="submit" name="submit" value="Get Started today!" />
</div>

&GT;