html表单php问题
这是我的html表单,下面是我的php文本 但是我没有得到正确的输出,我不知道问题出在哪里 我还包括输出,请建议我该怎么做html表单php问题,php,Php,这是我的html表单,下面是我的php文本 但是我没有得到正确的输出,我不知道问题出在哪里 我还包括输出,请建议我该怎么做 <html> <head> <title> Entering data into text </title> </head> <body> <h1> Entering data into text </h1> <form action="text.php" method=
<html>
<head>
<title>
Entering data into text
</title>
</head>
<body>
<h1>
Entering data into text
</h1>
<form action="text.php" method="post">
What is ur name ?
<input type="text" name="data" />
<input type="submit" value="send" />
</form>
</body>
</html>
问题是,在服务器响应之后,数据发送不包括在内
请尽快帮助我我只能根据自己的经验发言,但这在我的服务器上有效。那么,我认为以下其中一项是正确的:
“”
file:///path/to/file.html
),而不是通过服务器(http://localhost/file.html
)/var/www/directoryName/
,并通过http://localhost/directoryName/dataEntryForm.html
。如果您在Windows上,使用IIS,可以使用C:\inetPub\directoryName\
访问它,如上所述,使用http://localhost/directoryName/dataEntryForm.html
顺便说一句,请原谅我没有链接到页面运行的演示,只是我不想冒让我的服务器暴露在可能有漏洞的脚本中的风险。您的完整代码是这样的,我测试了它,工作得很好
<html>
<head>
<title>
Entering data into text
</title>
</head>
<body>
<h1>
Entering data into text
</h1>
<form action="text.php" method="post">
What is ur name ?
<input type="text" name="data" />
<input type="submit" value="send" name="btn_save" />
</form>
</body>
</html>
将数据输入文本
将数据输入文本
你叫什么名字?
text.php
<?php
if(isset($_POST['btn_save']))
{
$data=$_POST['data'];
}
?>
<html>
<head>
<title>
Reading data from textfields
</title>
</head>
<body>
<h1>
reading data from text field
</h1>
Thanks for answering,
<?php echo $_POST["data"];?>
</body>
</html>
从文本字段读取数据
从文本字段读取数据
谢谢你的回答,
工作完美。你能在text.php中打印你通过
print\r($\u REQUEST)
得到的东西吗?我是soory,请你再解释一下我是php新手,请帮助我这正是@amitchd想要做的。如他所问,如果您创建一个文本文件info.php
,请将print\r($\u REQUEST)
的结果输出发布到text.php=)中,其中只有
的内容,您得到了任何输出吗?如果web服务器没有为php配置,它不应该输出
?@gAMBOOKa:是的,它确实应该,但我使用了“[不是]“设置为处理php”是一个委婉的说法,其中包括“未正确设置”。此外,我没有想到。。。已编辑,我的感谢!=)@甘布卡:他只有在试图查看页面来源时才会看到它。在呈现的页面中,它将不可见。@JB:为什么它不可见?对于浏览器来说,它只是纯文本。@fariz,你为Stackoverflow的帮助所付出的代价是对社区的回报=)我建议将该评论作为一个答案发布,详细说明你为解决问题所做的一切。投票选出对你有帮助的答案。此外,它只是“大卫”(或者,最好是“大卫”),“先生”是值得赞赏的,但不必要=)
<html>
<head>
<title>
Entering data into text
</title>
</head>
<body>
<h1>
Entering data into text
</h1>
<form action="text.php" method="post">
What is ur name ?
<input type="text" name="data" />
<input type="submit" value="send" name="btn_save" />
</form>
</body>
</html>
<?php
if(isset($_POST['btn_save']))
{
$data=$_POST['data'];
}
?>
<html>
<head>
<title>
Reading data from textfields
</title>
</head>
<body>
<h1>
reading data from text field
</h1>
Thanks for answering,
<?php echo $_POST["data"];?>
</body>
</html>