Advertisement
Guest User

Untitled

a guest
Mar 1st, 2016
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.10 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=2>
  24. <tr>
  25. <th colspan=5>Editar 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 "<font color='red'>Registro Actualizado.</font><br><br>";
  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.  
  101.  
  102. ?>
  103.  
  104.  
  105. <?php
  106. if(isset($_POST["mail"]))
  107. {
  108.  
  109.  
  110.  
  111.  
  112. $to = $_POST['contacto'];
  113. $subject = "Su Cuenta Vence hoy";
  114. $message = "Hola , su cuenta de iptvlatinos vence hoy";
  115. $from = "iptvlatinos@gmail.com";
  116. $ok=(mail($to,$subject,$message,"-desde ".$from))
  117.  
  118. var_dump($ok);
  119.  
  120. if( $ok )
  121. echo "<p>El E-Mail ha sido enviado</p>";
  122. else
  123. echo "<p>ERROR al enviar el E-Mail</p>";
  124.  
  125.  
  126.  
  127.  
  128.  
  129.  
  130.  
  131. }
  132. ?>
  133.  
  134.  
  135.  
  136.  
  137. <!--we have our html form here where new user information will be entered-->
  138. <form action='#' method='post' border='0'>
  139. <table>
  140. <tr><br>
  141. <td>Username:</td>
  142. <td><input type='text' name='username' value='<?php echo $username; ?>' required="required"/></td>
  143. </tr>
  144. <tr>
  145. <td>Password:</td>
  146. <td><input type='text' name='clave' value='<?php echo $clave; ?>' required="required"/></td>
  147. </tr>
  148. <tr>
  149. <td>Mac Address:</td>
  150. <td><input type='text' name='macaddress' value='<?php echo $macaddress; ?>' /></td>
  151. </tr>
  152.  
  153. <tr>
  154. <td>IP Address:</td>
  155. <td><input type='text' name='ipaddress' value='<?php echo $ipaddress; ?>' /></td>
  156. </tr>
  157.  
  158. <tr>
  159. <td>Contacto:</td>
  160. <td><input type='text' name='contacto' value='<?php echo $contacto; ?>' /></td>
  161. </tr>
  162. <tr>
  163. <td>Expiracion:</td>
  164. <td><input type='date' name='expiracion' value='<?php echo $expiracion; ?>' /></td>
  165. <tr>
  166. <tr>
  167. <td>Mensaje:</td>
  168. <td><input type='text' name='mensaje' value='<?php echo $mensaje; ?>' /></td>
  169. <tr>
  170. <td></td>
  171. <td><p>
  172. <!-- so that we could identify what record is to be updated -->
  173. <input type='hidden' name='id' value='<?php echo $id ?>' />
  174.  
  175. <!-- we will set the action to edit -->
  176. <input type='hidden' name='action' value='update' />
  177. <input type='submit' value='Editar' class="btn-style" name='editar'/>
  178. <input type="button" name="Regresar" class="btn-style" value="Regresar" onClick="location.href='../panel/panel.php'" />
  179. <input type='submit' value='Email' class="btn-style" name='mail' />
  180.  
  181.  
  182.  
  183. </td>
  184. </tr>
  185. </table>
  186. </form>
  187.  
  188.  
  189.  
  190.  
  191.  
  192. </body>
  193. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement