我試圖獲得發佈信息和使用下面的代碼顯示的信息:隱藏屬性從HTML表單
PHP代碼:
$self = $_SERVER['PHP_SELF'];
if(isset($_POST['send'])){
$words = htmlspecialchars($_POST['board']);
print "<b>".$words."</b>";
}
HTML代碼:
上述<form action="<?php $self ?>" method=post> <!--$self is the directory of the page itself-->
<p><i>Comment</i></p>
<textarea name="board" rows="20" cols="10"></textarea>
<input name="send" type="hidden" />
<p><input type='submit' value='send' /></p>
</form>
代碼將工作,我intented。但是,如果我擺脫輸入名稱=「發送」的類型=「隱藏」,用戶輸入的消息將不會出現,一旦發送按鈕被點擊。爲什麼會發生?
什麼是你的提交按鈕的名稱? ;) –
您可以刪除'action =「」',因爲您將它指向同一頁面。 –