Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class customer{
- private $server = "localhost";
- private $user = "root";
- private $pass = "";
- public $dbname = "test4";
- function __construct(){
- $this->dbcon = new PDO("mysql:host=$this->server; dbname=$this->dbname", $this->user, $this->pass);
- }
- function insertData($p){
- try{
- $insert_query = "insert into customer(name, age, gender, email) values(:n, :a, :g, :e)";
- $result = $this->dbcon->prepare($insert_query);
- $result->bindParam("n", $_POST['name']);
- $result->bindParam("a", $_POST['age']);
- $result->bindParam("g", $_POST['gender']);
- $result->bindParam("e", $_POST['email']);
- $result->execute();
- ?>
- <script type="text/javascript">
- window.location.href="add.php";
- </script>
- <?php
- }catch(PDOException $e){
- echo "Error :" .$e->getMessage();
- }
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement