-2

送信後にHtmlフォームを非表示にするにはどうすればよいですか?フォームを再表示して結果をクリアするボタンが表示されますか?

<?php
if(isset($_POST['submit']))
{
    $name = $_POST['name'];
    echo "User Has submitted the form and entered this name : <b> $name </b>";
    echo "<br>You can use the following form again to enter a new name.";
}
?>
<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
   <input type="text" name="name"><br>
   <input type="submit" name="submit" value="Submit Form"><br>
</form>
4

3 に答える 3

0

注:HTMLをラップしたelse状態で

<?php
if(isset($_POST['submit']))
{
    $name = $_POST['name'];
    echo "User Has submitted the form and entered this name : <b> $name </b>";
    echo "<br>You can use the following form again to enter a new name.";
}
else{
?>
<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
   <input type="text" name="name"><br>
   <input type="submit" name="submit" value="Submit Form"><br>
</form>
<?php }?>
于 2013-02-22T09:52:25.850 に答える
0

form内側else全体を挿入するだけです

<?php
if(isset($_POST['submit']))
{
    $name = $_POST['name'];
    echo "User Has submitted the form and entered this name : <b> $name </b>";
    echo "<br>You can use the following form again to enter a new name.";
    echo "<a href='your_page.php'> Page</a>";
} else {
?>
 <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
  <input type="text" name="name"><br>
  <input type="submit" name="submit" value="Submit Form"><br>
 </form>
<?ph } ?>
于 2013-02-22T09:52:28.230 に答える
0
<form id="myform" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
    <input type="text" name="name"><br>
    <input type="submit" name="submit" value="Submit Form" onclick="document.getElementById('myform').style.display='none'"><br>
</form>
于 2013-02-22T09:52:51.673 に答える