简体   繁体   English

将数据从html传递给php

[英]passing data from html to php

dear all I am a beginer in PHP world (PHP 5.3.5) my web server is IIS fastCGI on win xp I tried to pass values from the HTML form to the php but the data are not passed 亲爱的,我是PHP世界的一个初学者(PHP 5.3.5)我的网络服务器是在win xp上的IIS fastCGI我试图将值从HTML表单传递给php但数据未通过

this is my html file 这是我的html文件

<html>
<body>
<form action="welcome.php" method="post">
Name: <input type="text" name="fname" />
Age: <input type="text" name="age" />
<input type="submit" />
</form>
</body>
</html> 

and this is my php file welcome.php 这是我的php文件welcome.php

<html>
<body>

Welcome <?php echo $_POST["fname"]; ?>!<br />
You are <?php echo $_POST["age"]; ?> years old.

</body>
</html> 

After pressing submit the output was like this 按下提交后输出就像这样

Welcome! 欢迎!
You are years old. 你今年岁。

but it should be like this 但它应该是这样的

Welcome John! 欢迎约翰!
You are 28 years old. 你今年28岁。

Can you please help me with this. 你能帮我解决这个问题吗?

on IIS change in the form: method="post" to method="POST" <-- UPPERCASE should solve your issue. 在IIS上更改形式:method =“post”to method =“POST”< - UPPERCASE应解决您的问题。

Anyway what about the apache? 无论如何apache呢? and PHP version around just 5, flat five :) 5.3.5 on IIS for the beginner? 和PHP版本只有5,平5:5.3.5在IIS上为初学者? sounds like to get the Mount Everest by night without gloves 听起来像没有戴手套的夜晚登上珠穆朗玛峰

That is pretty standard simple code, and looks correct. 这是非常标准的简单代码,看起来是正确的。 One thing you might look at is the way PHP is configured on your server. 您可能会看到的一件事是在服务器上配置PHP的方式。 Also, try using $_REQUEST in place of $_POST on your welcome.php page and see if it still does the same thing. 另外,尝试在welcome.php页面上使用$ _REQUEST代替$ _POST,看看它是否仍然做同样的事情。

Try naming your form as well 尝试命名您的表单

After looking at your code it seems that it must be a configuration issue. 查看代码后,似乎必须是配置问题。

Steps to resolve this: 解决此问题的步骤:

Firstly is the code that spits out the page actually welcome.php 首先是吐出页面的代码,实际上是welcome.php

Secondly add the following to your php block 其次将以下内容添加到您的php块中

var_dump($_POST);

Click submit and if this still shows 点击提交,如果仍然显示

array (
)

if so then do 如果是这样的话

var_dump($_REQUEST);

and post the contents to your post, and show us. 并将内容发布到您的帖子,并告诉我们。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM