【发布时间】:2014-03-07 20:54:48
【问题描述】:
我有一个简单的表单和 php 文件。当我单击提交时,它只会拉出一个包含 resources.php 内容的纯文本文件。为什么会发生这种情况?
index.html
<html>
<head>
</head>
<body>
<form action="resources.php" method='POST'>
<input type="text" placeholder="Name" name="name"><br>
<input type="text" placeholder="Organization" name="organization"><br>
<input type="email" placeholder="E-Mail" name="email"><br>
<input type="text" placeholder="Street Address" name="streetaddress"><br>
<input type="text" placeholder="Phone Number" name="phonenumber"><br>
<input type="text" placeholder="What is three plus four?" name="human"><br>
<input type="submit">
</form>
</body>
</html>
还有resources.php文件...
<html>
<head></head>
<body>
<?php
echo '<pre>'.$_POST.'<pre>';
?>
</body>
</html>
谢谢。
【问题讨论】:
-
如果您在 客户端上看到 PHP 代码,这意味着您的 Web 服务器没有处理该代码。您可能需要在服务器上重新安装和/或重新配置 PHP。
-
您的服务器未配置为执行 PHP,或者您已将文件保存为 .html,这些文件也不作为 PHP 执行。另外,
echo $_POST将不起作用。你只会得到字面意思Array作为输出。 -
您的网络服务器是否识别并执行 PHP 文件?例如,如果您使用的是 Apache,则需要在 conf 中的某处添加类似
AddType x-httpd-php .php的行,并且 libphp.so 文件需要作为模块提供。 -
@MarcB
print_r($_POST)