title: Save data to a database from a multi-page form Wordpress
body: <p>how to save data to a database from a multi-page form using sessions in wordpress?</p>
  <pre><code>session_start();
  foreach ($_POST as $key =&gt; $value) { 
      $_SESSION['post'][$key] = $value;
  }
  extract($_SESSION['post']);
  if (isset($_POST[&quot;submit&quot;])) {
      extract($_SESSION['post']);
      //global $wpdb;
      //$wpdb-&gt;insert(&quot;tablename&quot;, array(&quot;data&quot; =&gt; $_SESSION[&quot;data&quot;], array(&quot;%s&quot;));
      include 'dbconnect.php';
      try {
          $conn = new PDO(&quot;mysql:host=$servername;dbname=$dbname&quot;, $username, $password);
          $conn-&gt;setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
          $sql = &quot;INSERT INTO tablename ( data ) VALUES ( '{$data}' )&quot;;
          $conn -&gt;exec($sql);
      }
          catch(PDOException $e)
      {
          echo &quot;Connection failed: &quot; . $e-&gt;getMessage();
      }
          $conn = null;
          session_destroy();
      }
  </code></pre>
  <p>Trying to save a multi-page form to a database. I have no issues saving a single page form. However, once I try to use $_SESSION it will no longer save the data.
  Thank you in advance
  UPDATE: I could not get it to work using $wpdb; but it works just fine using PDO.</p>