【问题标题】:php echo not working properlyphp echo 无法正常工作
【发布时间】:2012-12-07 16:53:40
【问题描述】:

基本上,我想在 html 中制作一个简单的表单,并且我想在单击使用 php 提交后输出所有用户输入。到目前为止,它只是显示我输入的详细信息,但它没有让用户的数据回显它们。这是我的两个文件

输出.php:

<?php 
echo 'Name: '.$POST["name"].'<br /> Gender: '.$POST["gender"].'<br />Country: '.$POST["country"];
?>

testingformphp.html(表单部分):

    <form id="form" name="form" method="post" action="./PHP/output.php"/>
    Name<input name="name" type="text" id="name"/><br/>

    Gender<label><input type="radio" name="gender" id="gender_0" value="male"/>Male</label><br/>
    <label><input type="radio" name="gender" id="gender_1" value="female"/>Female</label><br/>

<select name="country" id="select">
    <optgroup title="europe">
    <option value="Russia">Russia</option>
    <option value="Greece">Greece</option>


    </optgroup>

    </select>


    <input type="submit" id="button" value="Submit"/>
    <input type="reset" id="reset" value="Reset"/>

    </form>

有人可以帮忙吗?

【问题讨论】:

  • $_POST 不是$POST
  • 也不要回显原始用户输入,将其传递给htmlspecialchars()

标签: php html echo forms http-post


【解决方案1】:

$POST 不存在,试试 $_POST。

【讨论】:

  • 谢谢!但现在它正在工作,但由于某种原因没有显示 Country 值
  • 确保值在数组中。做一个print_r($_POST);
【解决方案2】:
<?php 
echo 'Name: '.$_POST["name"].'<br /> Gender: '.$_POST["gender"].'<br />Country: '.$_POST["country"];
?>

http://www.tizag.com/phpT/postget.php查看post并获取方法。

【讨论】:

    猜你喜欢
    • 2019-01-13
    • 2015-11-15
    • 1970-01-01
    • 1970-01-01
    • 2021-08-16
    • 2012-10-28
    • 2013-10-13
    • 2012-12-06
    • 1970-01-01
    相关资源
    最近更新 更多