Advertisement
Guest User

Untitled

a guest
Feb 11th, 2016
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.01 KB | None | 0 0
  1. <?php
  2.  
  3.  
  4. include 'libs/config.inc.php';
  5.  
  6. session_start();
  7. if ($_SESSION["usuario"]["permiso"]!=1){
  8. header("location:index.html");
  9. $usuario==$_SESSION["usuario"];
  10. }
  11. ?>
  12.  
  13.  
  14. <!DOCTYPE HTML>
  15. <html>
  16. <head>
  17. <title>Editar clientes</title>
  18. <link rel="stylesheet" type="text/css" href="./css/panel.css" />
  19. </head>
  20. <body>
  21.  
  22. <center><h1>Panel De Administracion</h1><br><br>
  23. <center><table cellpadding=4 border=1>
  24. <tr>
  25. <th colspan=5>Agregar Usuarios</th
  26. ></tr>
  27.  
  28. <?php
  29. //include database connection
  30. include 'libs/db_connect.php';
  31.  
  32. $action = isset( $_POST['action'] ) ? $_POST['action'] : "";
  33. if($action == "update"){
  34. try{
  35.  
  36. //write query
  37. //in this case, it seemed like we have so many fields to pass and
  38. //its kinda better if we'll label them and not use question marks
  39. //like what we used here
  40. $query = "update usuarios
  41. set username = :username, clave = :clave, macaddress = :macaddress, ipaddress = :ipaddress, contacto = :contacto, expiracion = :expiracion, mensaje = :mensaje
  42. where id = :id";
  43.  
  44. //prepare query for excecution
  45. $stmt = $con->prepare($query);
  46.  
  47. //bind the parameters
  48. $stmt->bindParam(':username', $_POST['username']);
  49. $stmt->bindParam(':clave', $_POST['clave']);
  50. $stmt->bindParam(':macaddress', $_POST['macaddress']);
  51. $stmt->bindParam(':ipaddress', $_POST['ipaddress']);
  52. $stmt->bindParam(':contacto', $_POST['contacto']);
  53. $stmt->bindParam(':expiracion', $_POST['expiracion']);
  54. $stmt->bindParam(':mensaje', $_POST['mensaje']);
  55. $stmt->bindParam(':id', $_POST['id']);
  56.  
  57. // Execute the query
  58. if($stmt->execute()){
  59. echo "Registro Actualizado.";
  60. }else{
  61. die('No se puede actualizar registro.');
  62. }
  63.  
  64. }catch(PDOException $exception){ //to handle error
  65. echo "Error: " . $exception->getMessage();
  66. }
  67. }
  68.  
  69. try {
  70.  
  71. //prepare query
  72. $query = "select id, username, clave, macaddress, ipaddress, contacto, expiracion, mensaje from usuarios where id = ? limit 0,1";
  73. $stmt = $con->prepare( $query );
  74.  
  75. //this is the first question mark
  76. $stmt->bindParam(1, $_REQUEST['id']);
  77.  
  78. //execute our query
  79. $stmt->execute();
  80.  
  81. //store retrieved row to a variable
  82. $row = $stmt->fetch(PDO::FETCH_ASSOC);
  83.  
  84. //values to fill up our form
  85. $id = $row['id'];
  86. $username = $row['username'];
  87. $clave = $row['clave'];
  88. $macaddress = $row['macaddress'];
  89. $ipaddress = $row['ipaddress'];
  90. $contacto = $row['contacto'];
  91. $expiracion = $row['expiracion'];
  92. $mensaje = $row['mensaje'];
  93.  
  94. }catch(PDOException $exception){ //to handle error
  95. echo "Error: " . $exception->getMessage();
  96. }
  97.  
  98.  
  99.  
  100. //funcion de enviar mensaje
  101. $to = "satt_tv@hotmail.com, 7863269433@mymetropcs.com, 7862479847@tmomail.net";
  102. $subject = "Correo de prueba";
  103. $message = "Hola, este correo es una confirmación de que el correo se ha enviado";
  104. $from = "iptvlatinos@gmail.com";
  105. mail($to,$subject,$message,"From: $from");
  106. echo "El mensaje se ha enviado correctamente.";
  107.  
  108. ?>
  109.  
  110.  
  111. <!--we have our html form here where new user information will be entered-->
  112. <form action='#' method='post' border='0'>
  113. <table>
  114. <tr>
  115. <td>Username:</td>
  116. <td><input type='text' name='username' value='<?php echo $username; ?>' required="required"/></td>
  117. </tr>
  118. <tr>
  119. <td>Password:</td>
  120. <td><input type='text' name='clave' value='<?php echo $clave; ?>' required="required"/></td>
  121. </tr>
  122. <tr>
  123. <td>Mac Address:</td>
  124. <td><input type='text' name='macaddress' value='<?php echo $macaddress; ?>' /></td>
  125. </tr>
  126.  
  127. <tr>
  128. <td>IP Address:</td>
  129. <td><input type='text' name='ipaddress' value='<?php echo $ipaddress; ?>' /></td>
  130. </tr>
  131.  
  132. <tr>
  133. <td>Contacto:</td>
  134. <td><input type='text' name='contacto' value='<?php echo $contacto; ?>' /></td>
  135. </tr>
  136. <tr>
  137. <td>Expiracion:</td>
  138. <td><input type='date' name='expiracion' value='<?php echo $expiracion; ?>' /></td>
  139. <tr>
  140. <tr>
  141. <td>Mensaje:</td>
  142. <td><input type='text' name='mensaje' value='<?php echo $mensaje; ?>' /></td>
  143. <tr>
  144. <td></td>
  145. <td><p>
  146. <!-- so that we could identify what record is to be updated -->
  147. <input type='hidden' name='id' value='<?php echo $id ?>' />
  148.  
  149. <!-- we will set the action to edit -->
  150. <input type='hidden' name='action' value='update' />
  151. <input type='submit' value='Editar' class="btn-style" />
  152. <input type="button" name="Regresar" class="btn-style" value="Regresar" onClick="location.href='../panel/panel.php'">
  153. <input type="button" name="Mensaje" class="btn-style" value="Mensaje" onClick="location.href='../correo/enviar.php'">
  154.  
  155.  
  156.  
  157. </td>
  158. </tr>
  159. </table>
  160. </form>
  161.  
  162. </body>
  163. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement