0

plz help me to create a code in PHP
the INSERT operation is used with a Class which inserts data and go into the database.

3
Contributors
5
Replies
19
Views
4 Years
Discussion Span
Last Post by annyangel
0

**

customer.php

**

<?php

class Customer
{
    private $first_name;
    private $last_name;
    private $age;

    public function __construct()
    {
        $first_name = "";
        $last_name = "";
        $age = 0;
    }

    public function setdata($first_name, $last_name, $age)
    {
       $this -> first_name = $first_name;
       $this -> last_name = $last_name;
       $this -> age = $age; 
    }

    public function printdata()
    {
        echo "Name :" . $this -> first_name. "" . $this -> last_name;  
        echo "Age :" . $this -> age;
    }

}

  $c1 = new Customer();
  $c1 -> setdata("","","");
  $c1 -> printdata();
  $c2 = new Customer();
  $c2 -> setdata("","","");
  $c2 -> printdata();
  $c3 = new Customer();
  $c3 -> printdata();

?>  

**

index.php

**

<html>
<body>
<?php
if(isset($_GET['submit']))
{
    echo "Name" . $_GET['first_name'] . $_GET['last_name'] . "<br/>";
    echo "Age" . $_GET['age'] . "<br/>";
}
?>
<form enctype="multipart/form-data" action="entry.php" method="get">
First Name : <input type="text" name="first_name" /> <br />
Last Name : <input type="text" name="last_name" /> <br /> 
Age : <input type="text" name="age" size="27" /> <br/>
<input type="submit" value="Insert" name="submit" />
</form>
</body>
</html>
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.