Advertisement
Guest User

Untitled

a guest
Jan 23rd, 2019
263
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.31 KB | None | 0 0
  1. <?php
  2. include_once "controlador.php";
  3.  
  4.     class db
  5.     {
  6.         private $host="127.0.0.1:3306";
  7.         private $db= "bigdata";
  8.         private $user = "root";
  9.         private $password = "";
  10.         private $con = "";
  11.  
  12.        
  13.         function connect()
  14.         {
  15.             $this->con = mysqli_connect($this->host,$this->user,$this->password) or die ("error al conectar");
  16.             mysqli_select_db($this->con,$this->db)  or die ("error al seleccionar bd");
  17.  
  18.             if($this->con == ""){
  19.                 return false;
  20.             }
  21.         }
  22.  
  23.         function query($query){
  24.             if(mysqli_query($this->con,$query)){
  25.                 return true;
  26.             }
  27.             else{
  28.                 return false;
  29.             }
  30.         }
  31.     }
  32.  
  33.     class contacto extends db{
  34.         public $NC;
  35.         public $NombreA;
  36.         public $Sexo;
  37.         public $Domicilio;
  38.         public $Edad;
  39.         public $NoC;
  40.  
  41.         public function __construct($NC,$NombreA,$Sexo,$Domicilio,$Edad, $NoC){
  42.             $this->NC = $NC;
  43.             $this->NombreA = $NombreA;
  44.             $this->Sexo = $Sexo;
  45.             $this->Domicilio = $Domicilio;
  46.             $this->Edad = $Edad;
  47.             $this->NoC = $NoC;
  48.         }
  49.  
  50.         public function registro($contacto1){
  51.             $consulta = "INSERT INTO alumnos (NC,NombreA,Sexo,Domicilio,Edad, NoC) VALUES ($contacto1->NC,'$contacto1->NombreA','$contacto1->Sexo','$contacto1->Domicilio',$contacto1->Edad,$contacto1->NoC)";
  52.  
  53.             $this->connect();
  54.             if($this->query($consulta)){
  55.                 return true;
  56.             }
  57.             return false;
  58.         }
  59.     }
  60.  
  61. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement