Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- include 'libs/config.inc.php';
- session_start();
- if ($_SESSION["usuario"]["permiso"]!=1){
- header("location:index.html");
- $usuario==$_SESSION["usuario"];
- }
- ?>
- <!DOCTYPE HTML>
- <html>
- <head>
- <title>Editar clientes</title>
- <link rel="stylesheet" type="text/css" href="./css/panel.css" />
- </head>
- <body>
- <center><h1>Panel De Administracion</h1><br><br>
- <center><table cellpadding=4 border=1>
- <tr>
- <th colspan=5>Agregar Usuarios</th
- ></tr>
- <?php
- //include database connection
- include 'libs/db_connect.php';
- $action = isset( $_POST['action'] ) ? $_POST['action'] : "";
- if($action == "update"){
- try{
- //write query
- //in this case, it seemed like we have so many fields to pass and
- //its kinda better if we'll label them and not use question marks
- //like what we used here
- $query = "update usuarios
- set username = :username, clave = :clave, macaddress = :macaddress, ipaddress = :ipaddress, contacto = :contacto, expiracion = :expiracion, mensaje = :mensaje
- where id = :id";
- //prepare query for excecution
- $stmt = $con->prepare($query);
- //bind the parameters
- $stmt->bindParam(':username', $_POST['username']);
- $stmt->bindParam(':clave', $_POST['clave']);
- $stmt->bindParam(':macaddress', $_POST['macaddress']);
- $stmt->bindParam(':ipaddress', $_POST['ipaddress']);
- $stmt->bindParam(':contacto', $_POST['contacto']);
- $stmt->bindParam(':expiracion', $_POST['expiracion']);
- $stmt->bindParam(':mensaje', $_POST['mensaje']);
- $stmt->bindParam(':id', $_POST['id']);
- // Execute the query
- if($stmt->execute()){
- echo "Registro Actualizado.";
- }else{
- die('No se puede actualizar registro.');
- }
- }catch(PDOException $exception){ //to handle error
- echo "Error: " . $exception->getMessage();
- }
- }
- try {
- //prepare query
- $query = "select id, username, clave, macaddress, ipaddress, contacto, expiracion, mensaje from usuarios where id = ? limit 0,1";
- $stmt = $con->prepare( $query );
- //this is the first question mark
- $stmt->bindParam(1, $_REQUEST['id']);
- //execute our query
- $stmt->execute();
- //store retrieved row to a variable
- $row = $stmt->fetch(PDO::FETCH_ASSOC);
- //values to fill up our form
- $id = $row['id'];
- $username = $row['username'];
- $clave = $row['clave'];
- $macaddress = $row['macaddress'];
- $ipaddress = $row['ipaddress'];
- $contacto = $row['contacto'];
- $expiracion = $row['expiracion'];
- $mensaje = $row['mensaje'];
- }catch(PDOException $exception){ //to handle error
- echo "Error: " . $exception->getMessage();
- }
- //funcion de enviar mensaje
- $to = "satt_tv@hotmail.com, 7863269433@mymetropcs.com, 7862479847@tmomail.net";
- $subject = "Correo de prueba";
- $message = "Hola, este correo es una confirmación de que el correo se ha enviado";
- $from = "iptvlatinos@gmail.com";
- mail($to,$subject,$message,"From: $from");
- echo "El mensaje se ha enviado correctamente.";
- ?>
- <!--we have our html form here where new user information will be entered-->
- <form action='#' method='post' border='0'>
- <table>
- <tr>
- <td>Username:</td>
- <td><input type='text' name='username' value='<?php echo $username; ?>' required="required"/></td>
- </tr>
- <tr>
- <td>Password:</td>
- <td><input type='text' name='clave' value='<?php echo $clave; ?>' required="required"/></td>
- </tr>
- <tr>
- <td>Mac Address:</td>
- <td><input type='text' name='macaddress' value='<?php echo $macaddress; ?>' /></td>
- </tr>
- <tr>
- <td>IP Address:</td>
- <td><input type='text' name='ipaddress' value='<?php echo $ipaddress; ?>' /></td>
- </tr>
- <tr>
- <td>Contacto:</td>
- <td><input type='text' name='contacto' value='<?php echo $contacto; ?>' /></td>
- </tr>
- <tr>
- <td>Expiracion:</td>
- <td><input type='date' name='expiracion' value='<?php echo $expiracion; ?>' /></td>
- <tr>
- <tr>
- <td>Mensaje:</td>
- <td><input type='text' name='mensaje' value='<?php echo $mensaje; ?>' /></td>
- <tr>
- <td></td>
- <td><p>
- <!-- so that we could identify what record is to be updated -->
- <input type='hidden' name='id' value='<?php echo $id ?>' />
- <!-- we will set the action to edit -->
- <input type='hidden' name='action' value='update' />
- <input type='submit' value='Editar' class="btn-style" />
- <input type="button" name="Regresar" class="btn-style" value="Regresar" onClick="location.href='../panel/panel.php'">
- <input type="button" name="Mensaje" class="btn-style" value="Mensaje" onClick="location.href='../correo/enviar.php'">
- </td>
- </tr>
- </table>
- </form>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement