title: How to switch tabs in button click after saving data in mysql database in php?
body: <p>I am new to PHP, i started developing application using php, please look into my code</p>
  
  <p>index.php</p>
  
  <pre><code>&lt;?php require_once('./config.php'); ?&gt;
  &lt;?php
  
  /*
  * Following code will get single product details
  * A product is identified by product id (pid)
  */
  
  // array for JSON response
  $response = array();
  
  // check for required fields
  if (isset($_POST['name'])) {
  
  $title = $_POST['name'];
  $company = $_POST['company'];
  
  require_once('./db_connect.php');
  
  // connecting to db
  $db = new DB_CONNECT();
  
  // mysql inserting a new row
  $result = mysql_query("INSERT INTO user(name,company) VALUES('$title','$company')");
  }    
  
  ?&gt;
  &lt;html&gt;
  &lt;head&gt;
  &lt;link type="text/css" rel="Stylesheet" href="style.css" /&gt;
  &lt;script type="text/javascript" src="jquery-1.7.2.js"&gt;&lt;/script&gt;
  &lt;script type="text/javascript"&gt;
      $(window).load(function () {
          var tabContents = $(".tab_content").hide(),
          tabs = $("ul.tabs li");
  
          tabs.first().addClass("active").show();
          tabContents.first().show();
          tabs.click(function() {
          var $this = $(this), 
          activeTab = $this.find('a').attr('href');
          if(!$this.hasClass('active')){
          $this.addClass('active').siblings().removeClass('active');
          tabContents.hide().filter(activeTab).fadeIn();
          }
          return false;
          });
  
          $(".tabbutton").click(function () {
              var nextTab = parseInt($("li.active").attr("id"), 10) + 1;
              if (nextTab === 4) { nextTab = 1; }
              tabs.removeClass("active");
               $("#" + nextTab).addClass("active");
               tabContents.hide();
               $("#tab" + nextTab).fadeIn("slow");                
          });
      });
  &lt;/script&gt;
  &lt;script type="text/javascript" src="https://js.stripe.com/v1/"&gt;&lt;/script&gt;
  &lt;!-- jQuery is used only for this example; it isn't required to use Stripe --&gt;
  &lt;script type="text/javascript"  src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"&gt;&lt;/script&gt;
  &lt;script type="text/javascript"&gt;
  // this identifies your website in the createToken call below
  Stripe.setPublishableKey("&lt;?php echo $stripe['publishable_key']; ?&gt;");
  
  function stripeResponseHandler(status, response) {
      if (response.error) {
          // re-enable the submit button
          $('.submit-button').removeAttr("disabled");
          // show the errors on the form
          $(".payment-errors").html(response.error.message);
      } else {
          var form$ = $("#payment-form");
          // token contains id, last4, and card type
          var token = response['id'];
          // insert the token into the form so it gets submitted to the server
          form$.append("&lt;input type='hidden' name='stripeToken' value='" + token + "' /&gt;");
                  // and submit
          form$.get(0).submit();
      }
  }
  
  $(document).ready(function() {
      $("#payment-form").submit(function(event) {
          // disable the submit button to prevent repeated clicks
          $('.submit-button').attr("disabled", "disabled");
          // createToken returns immediately - the supplied callback submits the form if there are  no errors
          Stripe.createToken({
              number: $('.card-number').val(),
              cvc: $('.card-cvc').val(),
              exp_month: $('.card-expiry-month').val(),
              exp_year: $('.card-expiry-year').val()
          }, stripeResponseHandler);
          return false; // submit from callback
      });
  });
  </code></pre>
  
  <p></p>
  
  <p>
     Body part
     </p>
  
  <pre><code>&lt;ul class="tabs clearfix"&gt;
      &lt;li id="1"&gt;&lt;a href="#tab1"&gt;Tab1&lt;/a&gt;&lt;/li&gt;
      &lt;li id="2"&gt;&lt;a href="#tab2"&gt;Tab2&lt;/a&gt;&lt;/li&gt;
      &lt;li id="3"&gt;&lt;a href="#tab3"&gt;Tab3&lt;/a&gt;&lt;/li&gt;
  &lt;/ul&gt;
  
  &lt;div class="tab_container"&gt;
  &lt;div id="tab1" class="tab_content"&gt;
          &lt;form method="post"&gt;
  
              &lt;p&gt;
                      &lt;label&gt;Name:&lt;/label&gt; &lt;input type="text" name="name"&gt;
  
              &lt;/p&gt;
  
              &lt;p&gt;
                      &lt;label&gt;Company:&lt;/label&gt; &lt;input type="text" name="company"&gt;
              &lt;/p&gt;
             &lt;input type="submit" value="SAVE" class="tabbutton"/&gt;
      &lt;/form&gt;
  
      &lt;/div&gt;
  
  &lt;div id="tab2" class="tab_content"&gt; 
       &lt;form id="payment-form" action="charge.php" method="post"&gt;
  &lt;h3&gt;Purchase a quote by Oscar Wilde today! Only $535! Limited supply and going fast, buy now!!&lt;/h3&gt;
  &lt;!-- to display errors returned by createToken --&gt;
  &lt;span class="payment-errors"&gt;&lt;/span&gt;
  &lt;form action="charge.php" method="POST" id="payment-form"&gt;
      &lt;div class="form-row"&gt;
          &lt;label&gt;Card Number&lt;/label&gt;
              &lt;input type="text" size="20" autocomplete="off" class="card-number" /&gt;
      &lt;/div&gt;
      &lt;div class="form-row"&gt;
          &lt;label&gt;CVC&lt;/label&gt;
          &lt;input type="text" size="4" autocomplete="off" class="card-cvc" /&gt;
      &lt;/div&gt;
      &lt;div class="form-row"&gt;
          &lt;label&gt;Expiration (MM/YYYY)&lt;/label&gt;
          &lt;input type="text" size="2" class="card-expiry-month"/&gt;
          &lt;span&gt; / &lt;/span&gt;
          &lt;input type="text" size="4" class="card-expiry-year"/&gt;
      &lt;/div&gt;
      &lt;button type="submit" class="submit-button"&gt;Buy!&lt;/button&gt;
  &lt;/form&gt;
  &lt;/form&gt;
  &lt;/div&gt;
  
  
  &lt;div id="tab1" class="tab_content"&gt;
  &lt;p&gt;Tab 3 Content Goes Here...&lt;/p&gt;
  &lt;/div&gt;
  &lt;/div&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>In Tab1 I'm saving data into database. Whenever user clicks on the save button the data needs to be saved into database and it will go to Tab2. I am successful while saving the data. My problem is it is not going to Tab2 after saving the data. When we click on the save button, the tab2 is just blinking but the page is still showing tab1 content. I want that whenever the user clicks on the save button the data needs to be saved in database and it will go to Tab2 content.
  Any suggestions?</p>