送信時に(エラーがない場合)、同じページを更新し、連絡先フォームを削除して、「お問い合わせいただきありがとうございます」などのテキストに置き換えるphp連絡先フォームが必要です。これを行う最善の方法はありますか?
2 に答える
            2        
        
		
あなたはいつでも次のようなことをすることができます:
<?php
    $posted = false;
    if( isset($_POST['submit']) ) {
        /* Process $_POST */
        /* Do your things */
        /* Set a variable hinting if a post has been done */ 
        $posted = true;
    }
?>
<!DOCTYPE html>
<html>
    <body>
    <?php if( $posted ): ?>
        <form method="post">
            <input name="foo" />
            <input name="bar" />
            <input name="car" />
            <input name="submit" type="submit" value="Submit" />
        </form>
    <?php else: ?>
        <h1>Thank you for contacting us!</h1>
    <?php endif; ?>
    </body>
</html>
    于 2013-01-03T23:26:46.280   に答える
    
    
            0        
        
		
このようにしてください。
<?php
$showform=true;  //dispaying the form for the first time
if(isset($_POST['submit'])){
       //check for errors
       if($errors){
          $msg="errors";
          $showform=true;  // if found errors, setting error msg and displaying the form
       }else{
          //process the form
          $showform=false;  //if no errors, setting success msg and hiding the form
          $msg="SUccess";
       }
}
if(isset($msg)){
         //display the success/error msg
         echo $msg;
}
if($showform==true){
   //your form code
   <form method="post">
        <input name="foo" />
        <input name="bar" />
        <input name="car" />
        <input name="submit" type="submit" value="Submit" />
    </form>
}
?>
    于 2013-01-03T23:28:37.137   に答える