我已經寫在HTML表單,並且應該能夠生成輸入到同一目錄文本文件裏的PHP文件。我用不同的簡單的HTML文件之前測試了它和它的工作,現在我想將它應用到一個更大的HTML文件,並不知它不會工作,我找不到什麼不妥的地方。形式的HTML文本文件使用PHP
feedback.html:
<html>
<head>
<script>
function myFunction()
{
alert("Your feedback has been sent! Thank you");
}
</script>
</head>
<body>
<div class="Linksediv">
<h3>Feedback</h3>
<p>Please enter your name and give us some feedback</p>
<form action="form1.php" method="post">
Name<input id="Email" size="30" type="text" name="field1"/><br/>
<textarea id="pass" type="text" name="field2" rows="4" cols="24">Please give us some feedback
</textarea>
<br/>
<input type="button" name="submit" value="submit" id="buttonOk" onclick="myFunction()" value="Show alert box" />
</form>
</div>
</body>
</html>
Form1.php
<?php
if(isset($_POST['field1']) && isset($_POST['field2'])) { //Check if fields are there in HTML file
$data = $_POST['field1'] . ' - ' . $_POST['field2'] . "\n"; //output
$ret = file_put_contents('data1.txt', $data, FILE_APPEND | LOCK_EX); //file dir for data1.txt
if($ret === false) { //check if anything was written down
die('There was an error writing this file');
}
else {
echo "$ret bytes written to file"."\n";
}
}
?>
如果我按提交我的形式然後我就只能得到與警報彈出窗口,以及文本文件不會被寫入
你檢查你的錯誤日誌?你會得到什麼錯誤?你採取了哪些步驟來解決這個問題? – 2013-02-21 14:33:48
不Form1.php呼應什麼? – jimmy 2013-02-21 14:35:35
在我的錯誤日誌中沒有任何東西,正如我之前所說的,我在更小,更簡單的表單上測試了它,然後運行,現在它不會使用 – user2094841 2013-02-21 14:35:39