Guest User

Untitled

a guest
Jun 22nd, 2018
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.64 KB | None | 0 0
  1. <?php
  2. class datos
  3. {
  4. private $cadenaconexion;
  5. private $user;
  6. private $password;
  7. private $objetoconexion;
  8.  
  9. public function __construct($cadenaconexion, $user, $password)
  10. {
  11. $this -> cadenaconexion = $cadenaconexion;
  12. $this -> user = $user;
  13. $this -> password = $password;
  14. }
  15.  
  16. public function conectar()
  17. {
  18. try{
  19. $this -> objetoconexion = new PDO($this -> $cadenaconexion, $this -> $user, $this -> $password);
  20. $this -> objetoconexion -> setattribute(PDO::ATT_ERRMODE, PDO::ERRMODE_EXCEPTION);
  21. //echo "conectado";
  22. }catch(PDOExeption $e)
  23. {
  24. echo "Problemas para conectar con la base de datos";
  25. }
  26. }
  27.  
  28. public function desconectar()
  29. {
  30. $this -> objetoconexion = null;
  31. }
  32.  
  33. public function ejecutar($strComando){
  34. try{
  35. $ejecutar= $this -> objetoconexion-> prepare($strComando);
  36. $ejecutar -> execute();
  37. $rows = $ejecutar -> fetchAll();
  38. return $rows;
  39. }catch(PDOExeption $e){
  40. throw $e;
  41. }
  42. }
  43. }
  44.  
  45. ?>
  46.  
  47. <?php
  48. include_once '../Conexion/Datos.php';
  49.  
  50. class negocios{
  51. public $nombre;
  52. public $objetivo;
  53. public $imagen;
  54. public $arrastra;
  55. public $objetoDatos;
  56.  
  57. public function __construct($nombre, $objetivo, $imagen, $arrastra){
  58. $this-> nombre = $nombre;
  59. $this-> objetivo = $objetivo;
  60. $this-> imagen = $imagen;
  61. $this-> arrastra = $arrastra;
  62. $this-> objetoDatos= new Datos("mysqli: host=localhost; bdmame=bd_espamep","root","");
  63. }
  64.  
  65. public function insertarunidad(){
  66. try{
  67. $this-> objetoDatos -> conectar();
  68. $this-> objetoDatos -> ejecutar("INSERT INTO unidad(idempresa, uni-nombre, uni-objetivo, uni-logo, uni-eliminado) VALUES ('$this->nombre','$this->objetivo','$this->imagen','$this->arrastra')");
  69. $this-> objetoDatos -> desconectar();
  70. }catch (PDOException $e){
  71. throw $e;
  72. }
  73. }
  74.  
  75. }
  76. ?>
  77.  
  78. <?php
  79. require_once "../Control/negocios.php";
  80. ob_start();
  81.  
  82.  
  83. try{
  84. if(!empty($_POST))
  85. {
  86. $objetoNegocio= new negocios($_POST["txtunidad"], $_POST["txtobjetivou"], $_POST["logou"], 1);
  87.  
  88. if(isset($_POST["Guardar"]))
  89. {
  90. $objetoNegocio -> insertarunidad();
  91. }
  92. }
  93. }
  94. catch(PD0Eception $e)
  95. {
  96. echo $e -> getMessage();
  97. }
  98.  
  99. ?>
  100.  
  101.  
  102. <div class="content-wrapper">
  103. <!-- Content Header (Page header) -->
  104. <section class="content-header">
  105. <h1>
  106. ESPAMMFL-EP
  107. <small>ADMIN</small>
  108. </h1>
  109. <ol class="breadcrumb">
  110. <li><a href="Index.php"><i class="fa fa-dashboard"></i> Unidades</a></li>
  111. <li class="active">Panel Principal</li>
  112. </ol>
  113. </section>
  114. <!-- Main content -->
  115. <section class="content">
  116.  
  117. <div class="box box-primary">
  118. <div class="box-header with-border">
  119. <h3 class="box-title">Registro de <strong>UNIDADES</strong></h3>
  120. </div>
  121.  
  122. <form action="Unidades.php" method="POST" id="frmUnidades" name="frmUnidades" enctype="multipart/form-data" autocomplete="off">
  123. <!-- Small boxes (Stat box) -->
  124. <div class="box-body">
  125.  
  126.  
  127.  
  128.  
  129.  
  130. <div class="form-group">
  131. <label for="lblunidad">Nombre de Unidad:</label>
  132. <input type="text" class="form-control" id="txtunidad" name="txtunidad" placeholder="Ingrese nombre de la Unidad...">
  133. </div>
  134.  
  135. <div class="form-group">
  136. <label for="lblobjetivou">Objetivo:</label>
  137. <textarea type="text" class="form-control" id="txtobjetivou" name="txtobjetivou" placeholder="Ingrese Objetivo de la Unidad..."></textarea>
  138. </div>
  139.  
  140.  
  141. <div class="form-group">
  142. <label for="lblfoto">Logo de la Unidad:</label>
  143. <!--<input type="file" class="form-control" id="logou" name="logou" placeholder="Logo" accept="image/x-png,image/gif,image/jpeg">-->
  144.  
  145. <input type="text" class="form-control" id="logou" name="logou" placeholder="Ingrese nombre de la Unidad...">
  146. </div>
  147. <!--<div class="checkbox">
  148. <label>
  149. <input type="checkbox"> Check me out
  150. </label>
  151. </div>-->
  152.  
  153.  
  154.  
  155. </div>
  156. <!-- /.box-body -->
  157.  
  158. <div class="box-footer">
  159.  
  160. <input type="submit" name="Guardar" id="Guardar" value="Guardar" class="btn btn-primary">
  161. </div>
  162.  
  163. </form>
  164. </div>
  165. </section>
  166. <!-- /.content -->
  167. </div>
  168.  
  169.  
  170. <?php
  171. $contenido = ob_get_contents();
  172. ob_end_clean();
  173. require_once 'Master.php';
  174. ?>
Add Comment
Please, Sign In to add comment