Untitled
unknown
plain_text
3 years ago
1.7 kB
7
Indexable
<?php class Employee{ // Connection private $conn; // Table private $db_table = "Employee"; // Columns public $id; public $name; public $email; public $age; public $designation; public $created; // Db connection public function __construct($db){ $this->conn = $db; } } // CREATE ONE public function createEmployee(){ $sqlQuery = "INSERT INTO ". $this->db_table ." SET name = :name, email = :email, age = :age, designation = :designation, created = :created"; $stmt = $this->conn->prepare($sqlQuery); // sanitize $this->name=htmlspecialchars(strip_tags($this->name)); $this->email=htmlspecialchars(strip_tags($this->email)); $this->age=htmlspecialchars(strip_tags($this->age)); $this->designation=htmlspecialchars(strip_tags($this->designation)); $this->created=htmlspecialchars(strip_tags($this->created)); // bind data $stmt->bindParam(":name", $this->name); $stmt->bindParam(":email", $this->email); $stmt->bindParam(":age", $this->age); $stmt->bindParam(":designation", $this->designation); $stmt->bindParam(":created", $this->created); if($stmt->execute()){ return true; } return false; } } ?>
Editor is loading...