SHARE
TWEET

Untitled

a guest Jun 17th, 2019 92 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.   class Connection extends mysqli{
  3.     //Connection data
  4.     private $DB_NAME = "datos";
  5.     private $DB_TABLE = "user";
  6.     private $DB_HOST = "localhost";
  7.     private $DB_PASSWORD = "password";
  8.     private $DB_USER = "root";
  9.     public $DB_CHARSET = "utf8";
  10.  
  11.     //Constructor
  12.     public function __construct(){
  13.       parent::__construct($this->DB_HOST,$this->DB_USER,$this->$DB_PASSWORD,$this->DB_NAME);
  14.       if ($this->connect_errno) echo "<div class='mensaje'>Error:
  15.         {$this->connect_errno} -> {$this->connect_error}</div>";
  16.       $this->set_charset($this->$DB_CHARSET);
  17.     }
  18.  
  19.     //Insert new record
  20.     public function insert($id,$name,$password){
  21.       $sql_comand = "INSERT INTO {$this->DB_TABLE} VALUES (?,?,?)";
  22.       if(!($sentence = $this->prepare($sql_comand))){
  23.         echo "Error(prepare): {$this->connect_errno} -> {$this->connect_error}";
  24.       }
  25.       $sentence = $this->bind_param("iss",$id,$name,$password);
  26.       $sentence->execute();
  27.     }
  28.   }
  29.  
  30.   $conexion = new Connection();
  31. ?>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top