HTML:PHP不會發布我的HTML表單
<form method="post" action="create.php">
Job #: <input type="text" name="jobnum">
<br>
Program: <input type="text" name="program"><br />
Ship Date: <input type="text" name="shipdate"><br />
Description: <input type="text" style="height:100px; width:85%" name="description"><br /><br />
Proto Verified By: <input type="text" name="name"><br /><br />
Additional Notes: <input type="text" style="height:100px; width:85%" name="notes"><br />
<input type="submit" name="value" value="submit" />
</form>
PHP:
$savedata = $_REQUEST['savedata'];
if ($savedata == 1){
$data = $_POST['jobnum'] . "\r\n";
$data .= $_POST['program'] . "\r\n";
$data .= $_POST['description'] . "\r\n";
$data .= $_POST['name'] . "\r\n";
$data .= $_POST['notes'] . "\r\n";
$file = "YOURDATAFILE.txt";
$fp = fopen($file, "a") or die("Couldn't open $file for writing!");
fwrite($fp, $data) or die("Couldn't write values to file!");
fclose($fp);
echo "Your Form has been Submitted!";
}
我不知道爲什麼我的PHP不會發表自己的狀態。我的提交去了php頁面,但它完全是空白的。我有點新代碼,所以我可能需要一些詳細的答覆...
表單沒有'name'屬性。 – War10ck
該頁面是否爲空白?如果是這樣,你有錯誤,需要打開錯誤報告來看看它們。 –
如果頁面是空白的,用echo寫一個else if($ savedata == 1),看它是否迴應你的文本。如果是這樣,你知道$ savedata不是1! – SaschaP