Possible Duplicate:
Inserting values into database using object oriented programming
I am very new to the concept of object oriented in PHP . I have been trying to insert the values of my form to the database using object oriented concept. I do not receive any error message but the values are not getting updated on the database .
Kindly take a look at the code and let me know what changes I should be doing in order to make it work.
Input.php
<html>
<body>
<form action="database.php" method="post">
Name : <input type ="text" name = "name"/>
Number :<input type ="text" name = "number"/>
<input type ="submit" value = "submit"/>
</form>
</body>
</html>
database.php
<?php
class Database
{
var $host;
var $user;
var $pass;
var $data;
var $con;
var $table;
var $db;
public function hostname()
{
$this->host="localhost";
}
public function username()
{
$this->user="cgiadmin";
}
public function password()
{
$this->pass="cgi";
}
public function databasename()
{
$this->data="j2";
}
public function connection()
{
$this->con="mysql_connect($this->host,$this->user,$this->pass)";
}
public function tablename()
{
$this->table="Insert into table(name,number) values('$_POST[name]','$_POST[number]')";
}
public function databaseconnection()
{
$this->db="mysql_select_db($this->data,$this->con)";
}
public function mysql_close()
{
}
}
$name=new Database;
$name->connection();
$name->databaseconnection();
$name->tablename();
echo "thanks for taking the survey";
$name->mysql_close();
?>
Kindly let me know the changes which needs to be done . Thank you .
EDIT
I made a few changes and still it doesnt seem to worl . Please help
<?php
class Database
{
var $host;
var $user;
var $pass;
var $data;
var $con;
var $table;
var $db;
public function controls()
{
$this->host="localhost";
$this->user="cgiadmin";
$this->pass="cgi";
$this->data="j2";
}
public function connection()
{
$this->con="mysql_connect($this->host,$this->user,$this->pass)";
}
public function tablename()
{
$this->table="Insert into employee(name,number) values('$_POST[name]','$_POST[number]')";
}
public function databaseconnection()
{
$this->db="mysql_select_db($this->data,$this->con)";
}
}
$name=new Database;
$name->connection();
$name->databaseconnection();
$name->tablename();
echo "thanks for taking the survey";
?>