データをDBに送信し、次のページを読み込むPHPとSQL

データをDBに送信し、次のページを読み込むPHPとSQL

これは私が取り組んでいるテスト ページです。送信ボタンで次のページ「order.php」をロードできるようにしています。

同じページが読み込まれ続けます。これは PHP で記述すべきでしょうか、それとも HTML で記述すべきでしょうか?

私の送信ボタンを見ると、これは機能するはずだと私は思います。

<?php 
   ini_set('display_errors',1);
   ini_set('display_startup_errors',1);
   error_reporting(-1);
   require_once('connect2db.php');


   if(isset($_POST["action"])){ 

          $customer = $_POST['customer'];
          $Email = $_POST['Email'];


          $query = "INSERT INTO tbl_cust 
                (CName, email)
             VALUES 
                (:customer, :Email)";

          $sth = $db->prepare($query);
          $sth->bindValue(':customer', $customer, PDO::PARAM_STR);
          $sth->bindValue(':Email', $Email, PDO::PARAM_STR);
          $sth->execute();

          echo 'Form Submitted and data saved!';
   }


 ?>
<!DOCTYPE html>
<html class="html" lang="en-US">
   <head>
      <meta http-equiv="Content-type" content="text/html;     <title>Home</title>
   </head>
   <body>
      <div class="clearfix" id="page">
         <form class="form-grp clearfix colelem" id="widgetu75" method="post" enctype="multipart/form-data" action="">
           <input type="hidden" name="action" value="submit-form">
            <label>Name:</label>
            <input class="wrapped-input" type="text" spellcheck="false" id="widgetu86_input" name="customer" tabindex="1"/>
            <label>Email:</label>
            <input class="wrapped-input" type="text" spellcheck="false" id="widgetu82_input" name="Email" tabindex="2"/>
            <input class="submit-btn NoWrap grpelem" id="u81-17" type="submit" value="Submit" href="order.php" target="_blank"" ttabindex="3"/>
         </form>
      </div>
   </body>
</html>

答え1

アクションを「」から「order.php」に変更してみてください

関連情報