PHP在页面间传递变量
我对Joomla中的一段代码有问题。这可能与启用PHP的插件有关,但万一不是 第1页有一个表单PHP在页面间传递变量,php,variables,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
<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
?>
不幸的是,邮政编码没有回显如果没有其他原因导致此错误,请尝试命名要发送到
邮政编码
的输入:
<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>
在PHP代码中,您正在回显$\u 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>
试试这个
<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>
<?php
if (isset($_POST['submit'])){
echo $poster = $_POST['postcode'];
}else{
echo $poster = 1;
}