2015-10-14 135 views
-3

我在Joomla的一段代碼中遇到問題。這可能與使PHP啓用的插件有關,但如果不是的話。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 

?> 

不幸的是變量,郵政編碼不回顯

回答

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> 
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> 
0

試試這個

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

?>