表单变量不传递给php [英] form variables not passing to php
问题描述
我有一个简单的表单,我试图将表单变量传递给php并输出值。我试图用全能谷歌来解决这个问题,但没有成功。 html表单代码如下所示:
< html>
< head>
< title>表格< /标题>
< / head>
< body>
< form method =postaction =test1.php>
< input type =textname =username>
< input type =submit>
< / form>
< / body>
< / html>
然后php处理表单:
< HTML>
< head>
< title>表格< /标题>
< / head>
< body>
<?php
echo< h1> Hello。 $ _POST [用户名]。 < / H1> 中;
?>
< / body>
< / html>
无论我输入html表单的输出如何, _POST [username]。;?>
我不知道为什么它也输出结尾的分号和结尾的php标签,也许这是证据
PHP是
- 配置不当或
- 未配置或
您必须配置您的网络服务器,以便在HTML文件内解析PHP,例如:
I have a simple form and I'm trying to pass the form variable to php and output the value. I have tried to solve this myself with the almighty google but wasn't successful. The html form code is as follows
<html>
<head>
<title>Form</title>
</head>
<body>
<form method="post" action="test1.php">
<input type="text" name="username">
<input type="submit">
</form>
</body>
</html>
Then the php to handle the form is:
<html>
<head>
<title>Form</title>
</head>
<body>
<?php
echo "<h1>Hello " . $_POST["username"] . "</h1>";
?>
</body>
</html>
The output I'm getting no matter what I type into the html form is , Hello " . $_POST["username"] . ""; ?>
I don't know why it also outputs the ending semi colon and ending php tag also, maybe this is evidence of what's going wrong here?
PHP is
- misconfigured or
- not configured or
- not working or
- not working within HTML files.
You have to configure your webserver that it parses PHP inside HTML files, see here for example:
=> Server not parsing .html as PHP
这篇关于表单变量不传递给php的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!