title: Save form data in Database using classes
body: <p>I have a form. (Registration.php)</p>
  
  <pre><code>&lt;form action="reservation.php" onsubmit="return validateForm()" class="pure-form" id="form" method="POST"&gt; 
  &lt;label for="initials"&gt;Initials:&lt;/label&gt;&lt;input type="text" name="initials" id="initials" placeholder="initials" required&gt;&lt;br /&gt;
  &lt;label for="firstname"&gt;First name:&lt;/label&gt;&lt;input type="text" name="firstname" id="firstname" placeholder="firstname" required&gt;&lt;br /&gt;
  &lt;label for="surname"&gt;Surname:&lt;/label&gt;&lt;input type="text" name="surname" id="surname" placeholder="surname" required&gt;&lt;br /&gt;
  &lt;label for="country"&gt;Country:&lt;/label&gt;&lt;input type="text" name="country" id="country" placeholder="country" required&gt;&lt;br /&gt;
  &lt;label for="state"&gt;State:&lt;/label&gt;&lt;input type="text" name="state" id="state" placeholder="state" &gt;&lt;br /&gt;
  &lt;label for="province"&gt;Province:&lt;/label&gt;&lt;input type="text" name="province" id="province" placeholder="province" required&gt;&lt;br /&gt;
  &lt;label for="city"&gt;City:&lt;/label&gt;&lt;input type="text" name="city" id="city" placeholder="city" required&gt;&lt;br /&gt;
  &lt;label for="houseadress"&gt;Houseadress:&lt;/label&gt;&lt;input type="text" name="houseadress" id="houseadress" placeholder="houseadress" required&gt;&lt;br /&gt;
  &lt;label for="phone"&gt;Phone:&lt;/label&gt;&lt;input type="text" name="phone" id="phone" placeholder="phone" required&gt;&lt;br /&gt;
  &lt;label for="email"&gt;E-mail:&lt;/label&gt;&lt;input type="text" name="email" id="email" placeholder="email" required&gt;&lt;br /&gt;
  &lt;input type="submit" value="register" name="register"&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>And I have a class: (client.class.php)</p>
  
  <pre><code>class Client{
      private $clientID;
      private $initials;
      private $name;
      private $surname;
      private $country;
      private $state;
      private $province;
      private $city;
      private $houseadress;
      private $phone;
      private $email;
  
      public function __construct($clientID, $initials, $name, $surname, $country, $state, $province, $city, $houseadress, $phone, $email) {
          $this-&gt;clientID = $clientID;
          $this-&gt;initials = $initials;
          $this-&gt;name = $name;
          $this-&gt;surname = $surname;
          $this-&gt;country = $country;
          $this-&gt;state = $state;
          $this-&gt;province = $province;
          $this-&gt;city = $city;
          $this-&gt;houseadress = $houseadress;
          $this-&gt;phone = $phone;
          $this-&gt;email = $email;
      }
  }
  </code></pre>
  
  <p>And a Database connection: (database.php)</p>
  
  <pre><code>class Database {
      public $pdo;
  
      public function __construct() {
          // Connection information
          $host   = 'localhost:3307';
          $dbname = 'californiahotel';
          $user   = 'root';
          $pass   = 'usbw';
  
          // Attempt DB connection
          try
          {
              $this-&gt;pdo = new PDO("mysql:host=$host;dbname=$dbname", $user, $pass);
              $this-&gt;pdo-&gt;setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
              //echo 'Successfully connected to the database!';
          }
          catch(PDOException $e)
          {
              echo $e-&gt;getMessage();
          }
  
      }
       public function __destruct()
      {
          // Disconnect from DB
          $this-&gt;pdo = null;
          //echo 'Successfully disconnected from the database!';
      }
  }
  </code></pre>
  
  <p>I have been looking for weeks now to find out how to get the form data to the class (Client) and then to the class(Database) and then save it to the database! But I Didn't find anything that I needed.
  Perhaps someone can explain how it can be done?</p>