2012-04-25 115 views
-1

我无法在我的浏览器中打印$_POST的值。 这个form_methods.php有人可以告诉我这段代码有什么问题吗?

<html> 
    <head> 
     <title>Form Methods</title> 
    </head> 
    <body> 
     <form method="post" action="formoutputpage.php"> 
      <p><input type="text" name="greeting" size="15"></p> 
      <p><input type="text" name="name" size="15"></p> 
      <p><input type="submit" name="submit" value="Salutation"></p> 
     </form> 
    </body> 
</html> 

,这是formoutputpage.php

<? 
    echo $_POST['greeting']; 
    echo " ".$_POST['name']; 
    echo "!"; 
?> 
+0

是否回应任何事情,你已经启用了短标签? – jeroen 2012-04-25 01:19:30

回答

2

我觉得这个代码是OK。检查是否有任何未显示的错误。
因此,插入此代码顶部的formoutputpage.php准确显示所有错误。

<?php 
    ini_set('display_errors', 1); 
    error_reporting(E_ALL); 
?> 

并检查短标签是允许的。 <? =><?php
解析错误可能不会显示,具体取决于您的配置。

+0

ow!我知道了!短标签不起作用!谢谢! – 2012-04-25 01:29:47

+0

很高兴工作:))你会接受这个答案吗? – tosin 2012-04-25 01:37:32

+0

@Ran,[如果这个答案对你最有帮助,请接受它](http://meta.stackexchange.com/a/5235/157556)。谢谢! – sarnold 2012-04-25 01:37:52

0

您是否看到“!” ?

如果(假) OpenLink公司( 'http://www.php.net/manual/en/ini.core.php#ini.short-open-tag') 其他 回声 '我不\'然后知道”

+0

可爱,但请用简单的英语回答.. – sarnold 2012-04-25 01:22:04

+0

即将可爱。 – Ethan 2012-04-25 01:24:22

0

试试这个

<html> 
    <head> 
     <title>Form Methods</title> 
    </head> 
    <body> 
     <form method="post" action="formoutputpage.php"> 
      <input type="text" name="greeting" size="15" /> 
      <input type="text" name="name" size="15" /> 
      <input type="submit" name="submit" value="Salutation" /> 
     </form> 
    </body> 
</html> 

formoutputpage.php

<?php 
    if(isset($_POST['submit'])){ 
     echo $_POST['greeting'] . " " . $_POST['name'] . "!"; 
    }else{ 
     //do whatever you want 
    } 
?> 
+0

你改变了什么? – sarnold 2012-04-25 01:37:02

相关问题