title: Inputting two or more values to the database simultaneously
body: <p>I'm new with PHP, am I doing this right? The function of the code below will put the 2 values inside the database simultaneously. Once I input the values in the 2 text boxes, only the value in the first textbox is stored into the database. How can I store these two values into database with one form?</p>
  
  <p><strong>add.php</strong></p>
  
  <pre><code>    &lt;?php
      $con = mysql_connect("localhost","root","");
      if (!$con)
      {
      die('Could not connect: ' . mysql_error());
          }
  
      mysql_select_db("my_database", $con);
  
  
      mysql_close($con);
      ?&gt; 
  
      &lt;html&gt;
      &lt;body&gt;
  
      &lt;form action="insert.php" method="post" name="form1"&gt;
      Firstname: &lt;input type="text" name="firstname" /&gt;
      Firstname1: &lt;input type="text" name="firstname" /&gt;
  
      Age: &lt;input type="text" name="age" /&gt;
  
  
  
      &lt;input type="submit" name="form1" /&gt;
      &lt;/form&gt;
  
  
  
      &lt;/body&gt;
      &lt;/html&gt; 
  </code></pre>
  
  <p><strong>insert.php</strong>    </p>
  
  <pre><code>        &lt;html&gt;
       &lt;head&gt;
        &lt;title&gt;Record Added&lt;/title&gt;
        &lt;meta http-equiv="refresh" content="0;url=select.php"&gt;
       &lt;/head&gt;
       &lt;body&gt;
       &lt;?php
      $con = mysql_connect("localhost","root","");
      if (!$con)
        {
        die('Could not connect: ' . mysql_error());
        }
  
      mysql_select_db("my_database", $con);
  
      $sql="INSERT INTO biodata (FirstName)
      VALUES
      ('$_POST[firstname]')";
  
      if (!mysql_query($sql,$con))
        {
        die('Error: ' . mysql_error());
        }
      echo "1 record added";
  
      mysql_close($con);
      ?&gt; 
  
      &lt;a href="select.php"&gt; see&lt;/a&gt;
  
       &lt;/body&gt;
      &lt;/html&gt;
  </code></pre>
  
  <p><strong>select.php</strong></p>
  
  <pre><code>    &lt;?php
      $dbHost = 'localhost';
      $dbUser = 'root';
      $dbPass = '';
      $dbName = 'my_database';
  
      $dbConn = mysql_connect ($dbHost,$dbUser, $dbPass) or die ('MySQL connect failed. ' . mysql_error());
      mysql_select_db($dbName) or die('Cannot select database. ' . mysql_error());
  
      ?&gt;
  
      &lt;html&gt;
      &lt;head&gt;
      &lt;title&gt;Display&lt;/title&gt;
      &lt;/head&gt;
      &lt;table align="center" border=1&gt;
      &lt;tr&gt;
      &lt;th&gt; First Name&lt;/th&gt;
      &lt;th&gt;Last Name &lt;/th&gt;
      &lt;th&gt; Age &lt;/th&gt;
      &lt;/tr&gt;
  
      &lt;?php
      $query = "SELECT * FROM biodata";
      $result = mysql_query($query);
      while ($row = mysql_fetch_assoc($result)){
      ?&gt;
      &lt;tr&gt;&lt;td&gt;&lt;?php echo $row['FirstName'];?&gt;&lt;/td&gt;
  
      &lt;/tr&gt;
      &lt;?php }?&gt;
      &lt;/table&gt;
      &lt;/body&gt;
      &lt;/html&gt;
  </code></pre>