title: How to save DIV content to MySql
body: <p>How can i save the content of a DIV in MySql ?</p>
  
  <p>I have the scripts that connect the index.php with mydata_post.php where i call the data to be saved in MySql.</p>
  
  <p>Now the problem is where i try to save the data after getting displayed in a DIV i get empty content in MySql Table.</p>
  
  <p>The script works if i call from an Input instead a Div.</p>
  
  <p>The Div content that i want to save are in:</p>
  
  <pre><code>&lt;form name="form1" method="POST" action="mydata_post.php"&gt;
  
  
  &lt;div id="name2" name="name"&gt;&lt;/div&gt;
  &lt;div id="lastname2" name="lastname"&gt;&lt;/div&gt;
  
  &lt;input type="submit" name="Submit" value="Submit"&gt;
  
  
  &lt;/form&gt; 
  </code></pre>
  
  <p>Any one can help, where it can be the mistake?</p>
  
  <pre><code>    &lt;!DOCTYPE html&gt;
      &lt;html lang="en" xmlns:fb="https://www.facebook.com/2008/fbml"&gt;
          &lt;head&gt;
              &lt;meta charset="utf-8" /&gt;
  
              &lt;link href="main.css" rel="stylesheet" type="text/css" /&gt;
          &lt;/head&gt;
          &lt;body&gt;
  
  
  &lt;form name="form1" method="POST" action="mydata_post.php"&gt;
  
  
  &lt;div id="name2" name="name"&gt;&lt;/div&gt;
  &lt;div id="lastname2" name="lastname"&gt;&lt;/div&gt;
  
  &lt;input type="submit" name="Submit" value="Submit"&gt;
  
  
  &lt;/form&gt; 
              &lt;center&gt;
                  &lt;h1&gt;Authorization step:&lt;/h1&gt;
                  &lt;div id="user-info"&gt;&lt;/div&gt;
                  &lt;button id="fb-auth"&gt;Please login here&lt;/button&gt;
              &lt;/center&gt;
  
              &lt;div id="result_friends"&gt;&lt;/div&gt;
              &lt;div id="fb-root"&gt;&lt;/div&gt;
  
              &lt;script&gt;
              function sortMethod(a, b) {
                  var x = a.name.toLowerCase();
                  var y = b.name.toLowerCase();
                  return ((x &lt; y) ? -1 : ((x &gt; y) ? 1 : 0));
              }
  
              window.fbAsyncInit = function() {
                  FB.init({ appId: '&lt;?= $sApplicationId ?&gt;',
                      status: true,
                      cookie: true,
                      xfbml: true,
                      oauth: true
                  });
  
                  function updateButton(response) {
                      var button = document.getElementById('fb-auth');
  
                      if (response.authResponse) { // in case if we are logged in
                          var userInfo = document.getElementById('user-info');
                          var myname = document.getElementById('name2');
  
  
  
                          FB.api('/me', function(response) {
                              myname.innerHTML = response.name;
  
                              userInfo.innerHTML = '&lt;img name="userimage" src="https://graph.facebook.com/' + response.id + '/picture"&gt;'+ "&lt;br&gt; Your Name:" + response.name + "&lt;br&gt; Your ID:" + response.id ;
                              button.innerHTML = '&lt;div id="logout_bt"&gt;Logout&lt;/div';
                          });
  
                      // get friends
                      FB.api('/me/friends?limit=&lt;?= $iLimit ?&gt;', function(response) {
                          var result_holder = document.getElementById('result_friends');
                          var friend_data = response.data.sort(sortMethod);
  
                          var results = '';
                          for (var i = 0; i &lt; friend_data.length; i++) {
                              results += '&lt;div&gt;&lt;img src="https://graph.facebook.com/' + friend_data[i].id + '/picture"&gt;' + friend_data[i].name + "&lt;br&gt; Your ID:" + friend_data[i].id + '&lt;/div&gt;';
                          }
  
                              // and display them at our holder element
                              result_holder.innerHTML = '&lt;h2&gt;Result list of your friends:&lt;/h2&gt;' + results;
                          });
  
                      FB.api('/me/friends?limit=&lt;?= $iLimit ?&gt;', function(response) {
                          var id_holder = document.getElementById('lastname2');
                          var id_data = response.data.sort(sortMethod);
  
                          var id_results = '';
                          for (var i = 0; i &lt; id_data.length; i++) {
                              id_results += '&lt;div&gt; ' + id_data[i].id + '&lt;/div&gt;';
                          }
  
                              // and display them at our holder element
                              id_holder.innerHTML = '&lt;h2&gt;Result list of your friends:&lt;/h2&gt;' + id_results;
                          });
  
  
                          button.onclick = function() {
                              FB.logout(function(response) {
                                  window.location.reload();
                              });
                          };
                      } else { // otherwise - dispay login button
                          button.onclick = function() {
                              FB.login(function(response) {
                                  if (response.authResponse) {
                                      window.location.reload();
                                  }
                              }, {scope:''});
                          }
                      }
                  }
  
                  // run once with current status and whenever the status changes
                  FB.getLoginStatus(updateButton);
                  FB.Event.subscribe('auth.statusChange', updateButton);
              };
  
              (function() {
                  var e = document.createElement('script'); e.async = true;
                  e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js';
                  document.getElementById('fb-root').appendChild(e);
              }());
              &lt;/script&gt;
  
      &lt;/body&gt;
      &lt;/html&gt;
  </code></pre>
  
  <p>mydata_post.php - File</p>
  
  <pre><code> &lt;?php
  
      $host=""; // Host name
      $username=""; // Mysql username
      $password=""; // Mysql password
      $db_name=""; // Database name
      $tbl_name=""; // Table name
  
      // Connect to server and select database.
      mysql_connect("$host", "$username", "$password")or die("cannot connect");
      mysql_select_db("$db_name")or die("cannot select DB");
  
      // Get values from form
      $name=$_POST['name'];
      $lastname=$_POST['lastname'];
      $email=$_POST['email'];
  
      // Insert data into mysql
      $sql="INSERT INTO $tbl_name(name, lastname, email)VALUES('$name','$lastname','$email')";
      $result=mysql_query($sql);
  
      // if successfully insert data into database, displays message "Successful".
      if($result){
      echo "Successful";
      }
  
      else {
      echo "ERROR";
      }
  
      ?&gt;
  </code></pre>