【发布时间】:2012-10-10 16:03:23
【问题描述】:
我正在编写一个基本网页,其中一个要求是通过 php 文件提交输入的 html 表单。
我在 html 文件中编写了以下代码:
<form method="post" action="formsubmit.php" name="Contact Form" id="contactform" enctype="multipart/form-data">
<fieldset>
<legend align="center">
Your Details
</legend>
<p>
<label for="fname">First Name: </label>
<input type="text" id="fname" required/>
<label for="sname">Surname: </label>
<input type="text" id="sname" required/>
<label for="email">Email Address: </label>
<input type="email" id="email" required/>
<label for="phone">Phone Number: </label>
<input type="tel" id="phone" required/>
<br />
<br />
</p>
</fieldset>
<fieldset>
<legend align="center">
Third Parties
</legend>
<p>
<label for="sharedetails">Tick this box if you would like to recieve ticket and event information from our carefully selected third parties.</label>
<input type="checkbox" name="sharedetails" value="sharedetailsno" id="sharedetails" />
</p>
<p>
<input type="submit" value="Submit" />
<input type="reset" value="Clear" />
</p>
</fieldset>
</form>
然后创建以下php文件:
<html>
<head>
<title>Process Feedback</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<?php
$fname = $_POST["firstname"];
$sname = $_POST["surname"];
$email = $_POST["email"];
$phone = $_POST["phone"];
$sharedetails = $_POST["sharedetails"];
print "test test $fname $sname $email $phone test test";
?>
</body>
</html>
显然 php 文件仍处于测试阶段,我只希望它在使用正确的数据输出等正确格式化之前返回提交的数据
但每当我提交表单时,它都会不断返回“内部服务器错误”。我在互联网上搜索了答案并找到了类似的帖子,但没有一个对我的问题有帮助
我在本地系统上运行 apache 服务器。 ¿问题可能是配置错误吗?
如果我可以让表单数据正确提交到 php 文件,那么我可以格式化 html 页面/输出页面的其余部分。
【问题讨论】:
-
您的 HTTP 服务器的错误日志应该包含一条消息,指出此脚本运行失败的原因。
-
刚刚注意到我在字符集的 php 文件中遗漏了一个 ",已更正
-
您是否设置了 apache 以使用 php?你有一个工作的 hello world php 页面吗?
-
那些后置变量不存在。它们需要与输入的名称相同
-
John B- 你说得对,我使用了标签而不是输入 ID,我现在已经更正了,谢谢。
标签: php html forms internal-server-error