this is my contacts class
<?php
class contacts
{
private $name;
private $cno;
private $clocation;
public function __construct($name,$cno,$clocation)
{
$this->name = trim($name);
$this->cno =trim($cno);
$this->clocation=trim($clocation);
}
public function getName()
{
return $this->name;
}
public function getNO()
{
return $this->cno;
}
public function getLocation()
{
return $this->clocation;
}
}
class DataBaseAction extends contacts
{
private $db_info;
private $db_user;
private $db_pass;
private $db;
private $stmt;
public function __construct()
{
$this->db_info ='mysql:host=localhost;dbname=finalproject';
$this->db_user ='root';
$this->db_pass ='mrhot';
}
public static function insert_contact($sql)
{
$this->db = new PDO($this->db_info, $this->db_user, $this->db_user);
$this->stmt= $this->db->prepare($sql);
$this->stmt =execute(array('$this->getName()','$this->getNO()','$this->clocation()'));
$this->stmt =closeCursor();
}
}
and index.php fil e is
<!DOCTYPE HTML>
<html>
<body>
<form action='inc/post.in.php' method='post'>
contact name:
<input type ='text' name="cname" value="">
<br>
contact no:
<input type ='text' name="cno" value="">
<br>
location:
<input type ='text' name="clocation" value="">
<input type="submit" value="submit">
</form>
</body>
</html>
im getting this error when i submit the form
Fatal error: Using $this when not in object context in /opt/lampp/htdocs/pbook/inc/contacts.php on line 50