2013-02-22 29 views
-2

我怎樣才能使HTML表單提交dissepear後,它會顯示按鈕,使形式再次重現疏通結果呢?將HTML表單dissepear後提交

<?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> 

回答

0

注:else條件包裹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."; 
} 
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 }?> 
+0

請檢查該代碼,它按照工作您的要求 – 2013-02-22 10:02:00

+0

感謝無論如何使他們再次出現? – cton453 2013-02-22 10:11:29

+0

重定向頁面相同的URL,可以使用'標題(「位置:你url.php」);' – 2013-02-22 10:13:39

0

你必須只需插入你的整個formelse部分

<?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 } ?> 
+0

感謝反正讓他們再次出現? – cton453 2013-02-22 10:12:00

+0

@ cton453查看編輯答案。 – 2013-02-22 10:15:56

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> 
+0

但行動是在同一個頁面,所以它會在它提交後再次出現 – 2013-02-22 09:54:37

+0

啊,對我很慚愧。我沒有得到整個圖片。 – 2013-02-22 09:55:24