我正在編寫一個基本網頁,其中一項要求是通過php文件提交輸入的html表單。提交HTML/PHP表單時發生內部服務器錯誤
我已編碼的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服務器的錯誤日誌應該包含一條消息,說明爲什麼這個腳本運行失敗。 – cdhowie
只是注意到我錯過了「在PHP文件上的字符集,更正 –
你設置了Apache與PHP一起工作嗎?你有一個工作Hello世界的PHP頁面? –