Guest User

Untitled

a guest
Jun 22nd, 2018
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.67 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.  
  48. NEGOCIOS.PHP
  49.  
  50. <?php
  51. include_once '../Conexion/Datos.php';
  52.  
  53. class negocios{
  54. public $nombre;
  55. public $objetivo;
  56. public $imagen;
  57. public $arrastra;
  58. public $objetoDatos;
  59.  
  60. public function __construct($nombre, $objetivo, $imagen, $arrastra){
  61. $this-> nombre = $nombre;
  62. $this-> objetivo = $objetivo;
  63. $this-> imagen = $imagen;
  64. $this-> arrastra = $arrastra;
  65. $this-> objetoDatos= new Datos("mysqli: host=localhost; bdmame=bd_espamep","root","");
  66. }
  67.  
  68. public function insertarunidad(){
  69. try{
  70. $this-> objetoDatos -> conectar();
  71. $this-> objetoDatos -> ejecutar("INSERT INTO unidad(idempresa, uni-nombre, uni-objetivo, uni-logo, uni-eliminado) VALUES ('$this->nombre','$this->objetivo','$this->imagen','$this->arrastra')");
  72. $this-> objetoDatos -> desconectar();
  73. }catch (PDOException $e){
  74. throw $e;
  75. }
  76. }
  77.  
  78. }
  79. ?>
  80.  
  81.  
  82. UNIDADES.PHP
  83.  
  84. <?php
  85. require_once "../Control/negocios.php";
  86. ob_start();
  87.  
  88.  
  89. try{
  90. if(!empty($_POST))
  91. {
  92. $objetoNegocio= new negocios($_POST["txtunidad"], $_POST["txtobjetivou"], $_POST["logou"], 1);
  93.  
  94. if(isset($_POST["Guardar"]))
  95. {
  96. $objetoNegocio -> insertarunidad();
  97. }
  98. }
  99. }
  100. catch(PD0Eception $e)
  101. {
  102. echo $e -> getMessage();
  103. }
  104.  
  105. ?>
  106.  
  107.  
  108. <div class="content-wrapper">
  109. <!-- Content Header (Page header) -->
  110. <section class="content-header">
  111. <h1>
  112. ESPAMMFL-EP
  113. <small>ADMIN</small>
  114. </h1>
  115. <ol class="breadcrumb">
  116. <li><a href="Index.php"><i class="fa fa-dashboard"></i> Unidades</a></li>
  117. <li class="active">Panel Principal</li>
  118. </ol>
  119. </section>
  120. <!-- Main content -->
  121. <section class="content">
  122.  
  123. <div class="box box-primary">
  124. <div class="box-header with-border">
  125. <h3 class="box-title">Registro de <strong>UNIDADES</strong></h3>
  126. </div>
  127.  
  128. <form action="Unidades.php" method="POST" id="frmUnidades" name="frmUnidades" enctype="multipart/form-data" autocomplete="off">
  129. <!-- Small boxes (Stat box) -->
  130. <div class="box-body">
  131.  
  132.  
  133.  
  134.  
  135.  
  136. <div class="form-group">
  137. <label for="lblunidad">Nombre de Unidad:</label>
  138. <input type="text" class="form-control" id="txtunidad" name="txtunidad" placeholder="Ingrese nombre de la Unidad...">
  139. </div>
  140.  
  141. <div class="form-group">
  142. <label for="lblobjetivou">Objetivo:</label>
  143. <textarea type="text" class="form-control" id="txtobjetivou" name="txtobjetivou" placeholder="Ingrese Objetivo de la Unidad..."></textarea>
  144. </div>
  145.  
  146.  
  147. <div class="form-group">
  148. <label for="lblfoto">Logo de la Unidad:</label>
  149. <!--<input type="file" class="form-control" id="logou" name="logou" placeholder="Logo" accept="image/x-png,image/gif,image/jpeg">-->
  150.  
  151. <input type="text" class="form-control" id="logou" name="logou" placeholder="Ingrese nombre de la Unidad...">
  152. </div>
  153. <!--<div class="checkbox">
  154. <label>
  155. <input type="checkbox"> Check me out
  156. </label>
  157. </div>-->
  158.  
  159.  
  160.  
  161. </div>
  162. <!-- /.box-body -->
  163.  
  164. <div class="box-footer">
  165.  
  166. <input type="submit" name="Guardar" id="Guardar" value="Guardar" class="btn btn-primary">
  167. </div>
  168.  
  169. </form>
  170. </div>
  171. </section>
  172. <!-- /.content -->
  173. </div>
  174.  
  175.  
  176. <?php
  177. $contenido = ob_get_contents();
  178. ob_end_clean();
  179. require_once 'Master.php';
  180. ?>
Add Comment
Please, Sign In to add comment