title: Inserting values into database using object oriented programming
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/10919277/how-to-successfully-rewrite-old-mysql-php-code-with-deprecated-mysql-functions">How to successfully rewrite old mysql-php code with deprecated mysql_* functions?</a>  </p>
  </blockquote>
  
  
  
  <p>I have not been able to insert the values into the databse . However I do not get any error message as well . </p>
  
  <pre><code>&lt;html&gt;
  &lt;body&gt;
  &lt;form action="database.php" method="post"&gt;
  Name : &lt;input type ="text" name = "name"/&gt;
  Number  :&lt;input type ="text" name = "number"/&gt;
  &lt;input type ="submit" value = "submit"/&gt;
  &lt;/form&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>database.php</p>
  
  <pre><code>&lt;?php
  class Database
  {
      var $host;
      var $user;
      var $pass;
      var $data;
      var $con;
      var $table;
      var $db;
  
      public function controls()
      {
          $this-&gt;host="localhost";
          $this-&gt;user="cgiadmin";
          $this-&gt;pass="cgi";
          $this-&gt;data="j2";
      }
  
      public function connection()
      {
          $this-&gt;con="mysql_connect($this-&gt;host,$this-&gt;user,$this-&gt;pass)";
      }
      public function tablename()
      {
          $this-&gt;table="Insert into employee(name,number) values('$_POST[name]','$_POST[number]')";
      }
      public function databaseconnection()
      {
          $this-&gt;db="mysql_select_db($this-&gt;data,$this-&gt;con)";
      }
  
  }
  $name=new Database;
  $name-&gt;connection();
  if(!($name-&gt;con))
  {
      echo "'Error: ' . mysql_error()";
  }
  
  $name-&gt;databaseconnection();
  $name-&gt;tablename();
  
  echo "thanks for taking the survey";
  
  ?&gt;
  </code></pre>