使用面向对象编程概念进行php表单处理的问题[关闭]

I am very new to PHP . I was asked to create a very simple form in PHP using OOPS . I managed to create a single page form with 2 text fields (name and ID) but the issue I am facing now is that when user clicks on submit button only the name gets stored in the database but not the ID . Could you please help me out in this . Below is the sample code Thank You in advance

PERSON.PHP

<?php
class person
{
    var $id;
    var $name;
    function set_id($new_id)
    {
        $this->id=$new_id;
    }

    function get_id()
    {
        return $this->id;
    }

    function set_name($new_name)
    {
        $this->name=$new_name;
    }

    function get_name()
    {
        return $this->name;
    }
}
?>

DBINPUT.PHP

 <?php
 include 'person.php';
 ?>
 <html>
 <body>
 <form action="dbinsert.php" method="post">
  NAME<input type="text" name="name" >/
  ID<input type="text" name="ID" />
  <input type="submit" value="submit">
  </form>
  </html>
    </body>

DBINSERT.PHP

 <?php
    include("person.php");
    $con = mysql_connect("localhost", "cgiadmin", "cgi");
    if (!$con)
    {
        die("couldn't connect ".mysql_error());
    }
    mysql_select_db("oops", $con);

    $person = new person;
    $person->set_name($_POST['name']);

    $person1 = new person;
    $person1->set_id($_POST['id']);


    $sql="INSERT INTO smallprogramusingoops (NAME ,ID ) VALUES ('".$person->get_name()."','".$person1->get_id()."')";
    if (!mysql_query($sql, $con))
    {
    die('Error in inserting '.mysql_error());
    }

    ?>

Could you please rectify my mistake ?

The name attribute of your "id" field is in Block letters, while, when you access it via dbinsert.php, you use "id" instead of "ID".. Variables/indexes are case sensitive.

You create two objects. Not sure how PHP handles that, it might overwrite your existing variables.

Testrun this code:

<?php
include("person.php");
$con = mysql_connect("localhost", "cgiadmin", "cgi");
if (!$con)
{
    die("couldn't connect ".mysql_error());
}
mysql_select_db("oops", $con);

$person = new person();
$person->set_name($_POST['name']);
$person1->set_id($_POST['id']);


$sql="INSERT INTO smallprogramusingoops (NAME ,ID ) VALUES ('".$person->get_name()."','".$person1->get_id()."')";
if (!mysql_query($sql, $con))
{
die('Error in inserting '.mysql_error());
}

?>