提交資料到資料庫並載入下一頁 PHP 和 SQL

提交資料到資料庫並載入下一頁 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”

相關內容