Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class datos
- {
- private $cadenaconexion;
- private $user;
- private $password;
- private $objetoconexion;
- public function __construct($cadenaconexion, $user, $password)
- {
- $this -> cadenaconexion = $cadenaconexion;
- $this -> user = $user;
- $this -> password = $password;
- }
- public function conectar()
- {
- try{
- $this -> objetoconexion = new PDO($this -> $cadenaconexion, $this -> $user, $this -> $password);
- $this -> objetoconexion -> setattribute(PDO::ATT_ERRMODE, PDO::ERRMODE_EXCEPTION);
- //echo "conectado";
- }catch(PDOExeption $e)
- {
- echo "Problemas para conectar con la base de datos";
- }
- }
- public function desconectar()
- {
- $this -> objetoconexion = null;
- }
- public function ejecutar($strComando){
- try{
- $ejecutar= $this -> objetoconexion-> prepare($strComando);
- $ejecutar -> execute();
- $rows = $ejecutar -> fetchAll();
- return $rows;
- }catch(PDOExeption $e){
- throw $e;
- }
- }
- }
- ?>
- <?php
- include_once '../Conexion/Datos.php';
- class negocios{
- public $nombre;
- public $objetivo;
- public $imagen;
- public $arrastra;
- public $objetoDatos;
- public function __construct($nombre, $objetivo, $imagen, $arrastra){
- $this-> nombre = $nombre;
- $this-> objetivo = $objetivo;
- $this-> imagen = $imagen;
- $this-> arrastra = $arrastra;
- $this-> objetoDatos= new Datos("mysqli: host=localhost; bdmame=bd_espamep","root","");
- }
- public function insertarunidad(){
- try{
- $this-> objetoDatos -> conectar();
- $this-> objetoDatos -> ejecutar("INSERT INTO unidad(idempresa, uni-nombre, uni-objetivo, uni-logo, uni-eliminado) VALUES ('$this->nombre','$this->objetivo','$this->imagen','$this->arrastra')");
- $this-> objetoDatos -> desconectar();
- }catch (PDOException $e){
- throw $e;
- }
- }
- }
- ?>
- <?php
- require_once "../Control/negocios.php";
- ob_start();
- try{
- if(!empty($_POST))
- {
- $objetoNegocio= new negocios($_POST["txtunidad"], $_POST["txtobjetivou"], $_POST["logou"], 1);
- if(isset($_POST["Guardar"]))
- {
- $objetoNegocio -> insertarunidad();
- }
- }
- }
- catch(PD0Eception $e)
- {
- echo $e -> getMessage();
- }
- ?>
- <div class="content-wrapper">
- <!-- Content Header (Page header) -->
- <section class="content-header">
- <h1>
- ESPAMMFL-EP
- <small>ADMIN</small>
- </h1>
- <ol class="breadcrumb">
- <li><a href="Index.php"><i class="fa fa-dashboard"></i> Unidades</a></li>
- <li class="active">Panel Principal</li>
- </ol>
- </section>
- <!-- Main content -->
- <section class="content">
- <div class="box box-primary">
- <div class="box-header with-border">
- <h3 class="box-title">Registro de <strong>UNIDADES</strong></h3>
- </div>
- <form action="Unidades.php" method="POST" id="frmUnidades" name="frmUnidades" enctype="multipart/form-data" autocomplete="off">
- <!-- Small boxes (Stat box) -->
- <div class="box-body">
- <div class="form-group">
- <label for="lblunidad">Nombre de Unidad:</label>
- <input type="text" class="form-control" id="txtunidad" name="txtunidad" placeholder="Ingrese nombre de la Unidad...">
- </div>
- <div class="form-group">
- <label for="lblobjetivou">Objetivo:</label>
- <textarea type="text" class="form-control" id="txtobjetivou" name="txtobjetivou" placeholder="Ingrese Objetivo de la Unidad..."></textarea>
- </div>
- <div class="form-group">
- <label for="lblfoto">Logo de la Unidad:</label>
- <!--<input type="file" class="form-control" id="logou" name="logou" placeholder="Logo" accept="image/x-png,image/gif,image/jpeg">-->
- <input type="text" class="form-control" id="logou" name="logou" placeholder="Ingrese nombre de la Unidad...">
- </div>
- <!--<div class="checkbox">
- <label>
- <input type="checkbox"> Check me out
- </label>
- </div>-->
- </div>
- <!-- /.box-body -->
- <div class="box-footer">
- <input type="submit" name="Guardar" id="Guardar" value="Guardar" class="btn btn-primary">
- </div>
- </form>
- </div>
- </section>
- <!-- /.content -->
- </div>
- <?php
- $contenido = ob_get_contents();
- ob_end_clean();
- require_once 'Master.php';
- ?>
Add Comment
Please, Sign In to add comment