PageRenderTime 50ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 0ms

/neaticketwebapp/editUserNewEmp.php

https://gitlab.com/cesardemora/neaticketwebapphomeEs
PHP | 236 lines | 181 code | 39 blank | 16 comment | 14 complexity | 3a5eb4a2dc717d5f50fd335c67d6feee MD5 | raw file
  1. <?php
  2. require_once ('class/connect.php');
  3. $clase = new connect;
  4. $clase->dbConnects();
  5. $conn = dbConnect();
  6. $OK = true; // We use this to verify the status of the update.
  7. $msg = '';
  8. // If 'buscar' is in the array $_POST proceed to make the query.
  9. //if (isset($_GET['ide'])) {
  10. if(isset($_SESSION['email'])){
  11. mysql_query("SET NAMES 'utf8'");
  12. $consulta = "SELECT * FROM SECTORES ORDER BY id ASC";
  13. $resultado = mysql_query($consulta);
  14. $consulta2 = "SELECT * FROM CODIGOSBARRAS ORDER BY id ASC";
  15. $resultado2 = mysql_query($consulta2);
  16. // Create the query
  17. $sql = 'SELECT * FROM TIENDAS WHERE mail = ?';
  18. // we have to tell the PDO that we are going to send values to the query
  19. $stmt = $conn->prepare($sql);
  20. // Now we execute the query passing an array toe execute();
  21. $results = $stmt->execute(array($_SESSION['email']));
  22. // Extract the values from $result
  23. $row = $stmt->fetch();
  24. if (empty($row)) {
  25. $result = "No se encontraron resultados !!";
  26. }
  27. }
  28. // remove comment to verify the information in the $_POST array.
  29. // var_dump($_POST);
  30. if (array_key_exists('update', $_POST)) {
  31. // Create the query
  32. $sql = 'UPDATE TIENDAS SET password = ?, direccion = ?, cp = ?, telefono = ?, telefono_servicio = ?, web = ?, correo_info = ?, dias_devolucion = ?, meses_garantia = ?, sector = ?, horario = ?, moneda = ?, localidad = ?, tipo_barras = ?, id_tienda = ? WHERE mail = ?';
  33. // we have to tell the PDO that we are going to send values to the query
  34. $stmt = $conn->prepare($sql);
  35. // Now we execute the query passing an array to execute();
  36. $OK = $stmt->execute(array($_POST['pass'],$_POST['direccion'],$_POST['cp'],$_POST['telefono'],$_POST['telefono_servicio'],$_POST['web'],$_POST['correo_info'],$_POST['dias_devolucion'],$_POST['meses_garantia'],$_POST['Sectores'],$_POST['horario'],$_POST['moneda'],$_POST['localidad'],$_POST['tipo_barras'],$_POST['id_tienda'],$_SESSION['email']));
  37. // In case of any error, we get the values.
  38. $error = $stmt->errorInfo();
  39. // We use this to verify the integrity of the update.
  40. if (!$OK) {
  41. echo $error[2];
  42. } else {
  43. // echo '<p>El registro se actualizo correctamente</p>';
  44. //header("refresh: 0;editUserNewEmp.php?ide=".$_GET['ide']);
  45. header("refresh: 0;index2emp.php");
  46. exit;
  47. }
  48. }
  49. ?>
  50. <!DOCTYPE html>
  51. <html lang="en">
  52. <head>
  53. <?php include("lib/headNew.php"); ?>
  54. </head>
  55. <body>
  56. <!-- Top menu -->
  57. <nav class="navbar navbar-inverse navbar-no-bg" role="navigation">
  58. <?php include("lib/navNew.php"); ?>
  59. </nav>
  60. <!-- Loader -->
  61. <div class="loader">
  62. <div class="loader-img"></div>
  63. </div>
  64. <div class="container">
  65. <div class="row">
  66. <div id="capa" class="container wow fadeInUp">>
  67. <?php
  68. // If there are no records.
  69. if(!$OK) :
  70. echo "";
  71. else :
  72. ?>
  73. <div class="jumbotron">
  74. <h1>Editar<strong> Perfil</strong> Empresa</h1>
  75. <form form role="form" class="registration-form" name="login_user" id="form1" method="post" action="">
  76. <div>
  77. <div class="form-group">
  78. <label class="sr-only2" for="ide">Email Tienda</label>
  79. <input type="text" name="ide" id="ide" disabled="disabled" value="<?php echo $row['mail'];?>" class="form-first-name form-control">
  80. </div>
  81. <div class="form-group">
  82. <label class="sr-only2" for="marca">Nombre Marca</label>
  83. <input type="text" name="marca" id="marca" disabled="disabled" value="<?php echo $row['nombre_marca'];?>" class="form-first-name form-control">
  84. </div>
  85. <div class="form-group">
  86. <label class="sr-only2" for="cif">CIF</label>
  87. <input type="text" name="cif" id="cif" disabled="disabled" value="<?php echo $row['cif_empresa'];?>" class="form-first-name form-control">
  88. </div>
  89. <div class="form-group">
  90. <label class="sr-only2" for="form-id">Password</label>
  91. <input type="text" name="pass" id="pass" value="<?php echo $row['password'];?>" class="form-first-name form-control" required>
  92. </div>
  93. <div class="form-group">
  94. <label class="sr-only2" for="form-id">Identificador Tienda</label>
  95. <input type="text" name="id_tienda" id="id_tienda" value="<?php echo $row['id_tienda'];?>" class="form-first-name form-control" required>
  96. </div>
  97. <div class="form-group">
  98. <label class="sr-only2" for="form-nick">Dirección</label>
  99. <input type="text" name="direccion" id="direccion" value="<?php echo $row['direccion'];?>" class="form-first-name form-control" required>
  100. </div>
  101. <div class="form-group">
  102. <label class="sr-only2" for="form-id">Código Postal</label>
  103. <input type="number" name="cp" id="cp" value="<?php echo $row['cp'];?>" class="form-first-name form-control" required>
  104. </div>
  105. <div class="form-group">
  106. <label class="sr-only2" for="form-id">Localidad</label>
  107. <input type="text" name="localidad" id="localidad" value="<?php echo $row['localidad'];?>" class="form-first-name form-control" required>
  108. </div>
  109. <div class="form-group">
  110. <label class="sr-only2" for="form-id">Teléfono</label>
  111. <input type="number" name="telefono" id="telefono" value="<?php echo $row['telefono'];?>" class="form-first-name form-control" required>
  112. </div>
  113. <div class="form-group">
  114. <label class="sr-only2" for="form-id">Teléfono Servicio Técnico</label>
  115. <input type="number" name="telefono_servicio" id="telefono_servicio" value="<?php echo $row['telefono_servicio'];?>" class="form-first-name form-control">
  116. </div>
  117. <div class="form-group">
  118. <label class="sr-only2" for="form-id">Web</label>
  119. <input type="text" name="web" id="web" value="<?php echo $row['web'];?>" class="form-first-name form-control" placeholder="www.example.com">
  120. </div>
  121. <div class="form-group">
  122. <label class="sr-only2" for="form-id">Correo de Contacto</label>
  123. <input type="email" name="correo_info" id="correo_info" value="<?php echo $row['correo_info'];?>" class="form-first-name form-control">
  124. </div>
  125. <div class="form-group">
  126. <label class="sr-only2" for="form-id">Días de Devolución</label>
  127. <input type="number" maxlength="3" name="dias_devolucion" id="dias_devolucion" value="<?php echo $row['dias_devolucion'];?>" class="form-first-name form-control" required>
  128. </div>
  129. <div class="form-group">
  130. <label class="sr-only2" for="form-id">Meses de Garantía</label>
  131. <input type="number" maxlength="3" name="meses_garantia" id="meses_garantia" value="<?php echo $row['meses_garantia'];?>" class="form-first-name form-control" required>
  132. </div>
  133. <div class="form-group">
  134. <label class="sr-only2" for="form-id">Sector: </label>
  135. <select name="Sectores" class="form-group" >
  136. <?php
  137. $sector = $row['sector'];
  138. while ($fila= mysql_fetch_assoc($resultado)){
  139. if ($fila['nombre']==$sector)
  140. $seleccion = "selected";
  141. else
  142. $seleccion = "";
  143. if ($fila['nombre']!="Todos")
  144. echo "<option value='".$fila['nombre']."' ".$seleccion.">".$fila['nombre']."</option>";
  145. }
  146. ?>
  147. </select>
  148. </div>
  149. <div class="form-group">
  150. <label class="sr-only2" for="form-id">Horario</label>
  151. <input type="text" name="horario" id="horario" value="<?php echo $row['horario'];?>" class="form-first-name form-control">
  152. </div>
  153. <div class="form-group">
  154. <label class="sr-only2" for="form-id">Moneda</label>
  155. <input type="text" maxlength="3" name="moneda" id="moneda" value="<?php echo $row['moneda'];?>" class="form-first-name form-control" placeholder="EUR">
  156. </div>
  157. <div class="form-group">
  158. <label class="sr-only2" for="form-id">Tipo Código de Barras</label>
  159. <select name="tipo_barras" class="form-group" >
  160. <?php
  161. $tipo = $row['tipo_barras'];
  162. while ($fila2= mysql_fetch_assoc($resultado2)){
  163. if ($fila2['nombre']==$tipo)
  164. $seleccion = "selected";
  165. else
  166. $seleccion = "";
  167. echo "<option value='".$fila2['nombre']."' ".$seleccion.">".$fila2['nombre']."</option>";
  168. }
  169. ?>
  170. </select>
  171. </div>
  172. <div class="form-group btn2">
  173. <button type="submit" name="update" class="btn4">Actualizar</button>
  174. <a href="index2emp.php"><button name="boton2" id="boton2" type="button" class="btn">
  175. <span class="typcn typcn-arrow-left"></span> Volver</button></a>
  176. </div>
  177. </div>
  178. <?php endif;?>
  179. </form>
  180. </div>
  181. <!-- </form> -->
  182. </div>
  183. </div>
  184. </div> <!--/ .container -->
  185. <!-- MODAL: Privacy policy -->
  186. <?php include("lib/modalNew.php"); ?>
  187. <!-- Javascript -->
  188. <script type="" src="assetsNew/js/jquery-1.11.3.min.js"></script>
  189. <script type="" src="assetsNew/js/bootstrap.min.js"></script>
  190. <script type="" src="assetsNew/js/jquery.backstretch.min.js"></script>
  191. <script type="" src="assetsNew/js/retina-1.1.0.min.js"></script>
  192. <script type="" src="assetsNew/js/wow.min.js"></script>
  193. <script type="" src="assetsNew/js/scripts.js"></script>
  194. <script type="" src="assetsNew/js/scripts-screen.js"></script>
  195. <script type="" src="assetsNew/js/main.js"></script>
  196. </body>
  197. </html>