Daten an die Datenbank senden und nächste Seite laden PHP und SQL

Daten an die Datenbank senden und nächste Seite laden PHP und SQL

Dies ist nur eine Testseite, an der ich arbeite. Ich versuche, meinen Absenden-Button dazu zu bringen, die nächste Seite „order.php“ zu laden.

Es wird immer dieselbe Seite geladen. Soll ich das in PHP oder HTML schreiben?

Wenn Sie sich meine Schaltfläche „Senden“ ansehen, denke ich, dass dies funktionieren sollte.

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

Antwort1

Versuchen Sie, Ihre Aktion von "" in "order.php" zu ändern.

verwandte Informationen