フォームが提出されたら、何かを返信したい。しかし、私が[送信]ボタンをクリックすると、ページがちょうどリフレッシュされているように見えて、エコーセクションに書かれた単語が表示されません。私のコードは次のとおりです:フォームが提出されていないかチェックする。
<?php
if (isset($_POST['submit'])) {
echo "submitted";
}
?>
<h3>Post your form here</h3>
<form method="post" action="<?php $_SERVER['PHP_SELF']; ?>">
<label>Insert a title here</label><br>
<input name="title" type="text" placeholder="add a title"><br><br>
<label>Insert the body here</label><br>
<textarea name="body" placeholder="insert the body here "></textarea><br><br>
<input type="submit" value="submit" name="submit"><br>
</form>
また、isset関数を削除してコードを試しましたが、これもうまくいきませんでした。
まだ動作しません! – NinaDev
私はちょうど正確なコードを試して、うまくいった。エラーを有効にして、エラーが出るかどうか確認できますか?'error_reporting(E_ALL);' 'ini_set(" display_errors "、" On ");' –
指定したコードはどこに置くべきですか? – NinaDev