Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- include_once "controlador.php";
- class db
- {
- private $host="127.0.0.1:3306";
- private $db= "bigdata";
- private $user = "root";
- private $password = "";
- private $con = "";
- function connect()
- {
- $this->con = mysqli_connect($this->host,$this->user,$this->password) or die ("error al conectar");
- mysqli_select_db($this->con,$this->db) or die ("error al seleccionar bd");
- if($this->con == ""){
- return false;
- }
- }
- function query($query){
- if(mysqli_query($this->con,$query)){
- return true;
- }
- else{
- return false;
- }
- }
- }
- class contacto extends db{
- public $NC;
- public $NombreA;
- public $Sexo;
- public $Domicilio;
- public $Edad;
- public $NoC;
- public function __construct($NC,$NombreA,$Sexo,$Domicilio,$Edad, $NoC){
- $this->NC = $NC;
- $this->NombreA = $NombreA;
- $this->Sexo = $Sexo;
- $this->Domicilio = $Domicilio;
- $this->Edad = $Edad;
- $this->NoC = $NoC;
- }
- public function registro($contacto1){
- $consulta = "INSERT INTO alumnos (NC,NombreA,Sexo,Domicilio,Edad, NoC) VALUES ($contacto1->NC,'$contacto1->NombreA','$contacto1->Sexo','$contacto1->Domicilio',$contacto1->Edad,$contacto1->NoC)";
- $this->connect();
- if($this->query($consulta)){
- return true;
- }
- return false;
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement