0% found this document useful (0 votes)
31 views5 pages

Sitiomodal

The document contains code for a PHP web application that displays a table of users from a database and includes functionality to edit user details. Index.php displays the user table and includes EditModal.php which contains a modal form to edit user names. EditRegistro.php contains the PHP code to update the database with the edited user name when the form is submitted.

Uploaded by

albertozapata
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
31 views5 pages

Sitiomodal

The document contains code for a PHP web application that displays a table of users from a database and includes functionality to edit user details. Index.php displays the user table and includes EditModal.php which contains a modal form to edit user names. EditRegistro.php contains the PHP code to update the database with the edited user name when the form is submitted.

Uploaded by

albertozapata
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Index.

php

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Usuarios</title>
<link rel="stylesheet" type="text/css" href="bootstrap/css/bootstrap.min.css">
</head>
<body>

<div class="container">
<h1 class="page-header text-center">Lista de Usuarios</h1>
<div class="row">
<div class="col-sm-8 col-sm-offset-2">

<table class="table table-bordered table-striped" style="margin-top:20px;">


<thead>
<th>Usuario</th>
<th>Nombre</th>
<th>Editar</th>
</thead>
<tbody>
<?php
//incluimos el fichero de conexion
include_once('conectar.php');
$checar= "SELECT * FROM usuarios";
//echo $checar;
$resultado = pg_query($conn,$checar);
while($row = pg_fetch_array($resultado))
{
?>
<tr>
<td><?php echo $row['usuario']; ?></td>
<td><?php echo $row['ncompleto']; ?></td>
<td>
<a href="#edit_<?php echo $row['usuario']; ?>" class="btn btn-success btn-sm" data-
toggle="modal"><span class="glyphicon glyphicon-edit"></span> Editar</a>
</td>
<?php include('EditarModal.php'); ?>
</tr>

<?} ?>
</tbody>
</table>
</div>
</div>
</div>

<script src="js/jquery.min.js"></script>
<script src="bootstrap/js/bootstrap.min.js"></script>
</body>
</html>
EditarModal.php

<div class="modal fade" id="edit_<?php echo $row['usuario']; ?>" tabindex="-1" role="dialog" aria-
labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
<center><h4 class="modal-title" id="myModalLabel">Editar usuario</h4></center>
</div>
<div class="modal-body">
<div class="container-fluid">
<form method="POST" action="EditarRegistro.php?user=<?php echo $row['usuario']; ?>">
<div class="row form-group">
<div class="col-sm-2">
<label class="control-label" style="position:relative; top:7px;">Nombre:</label>
</div>
<div class="col-sm-10">
<input type="text" class="form-control" name="nombres" value="<?php echo
$row['ncompleto']; ?>">
</div>
</div>

</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal"><span class="glyphicon
glyphicon-remove"></span> Cancel</button>
<button type="submit" name="editar" class="btn btn-success"><span class="glyphicon glyphicon-
check"></span> Actualizar</a>
</form>
</div>

</div>
</div>
</div>
EditarRegistro.php
<?php
include_once('conectar.php');

if(isset($_POST['editar'])){

$user = $_GET['user'];
$nombre= $_POST['nombres'];
$actua="UPDATE usuarios SET ncompleto='$nombre' where upper(USUARIO)='".strtoupper($user)."'";
echo $actua;
$resultado = pg_query($conn,$actua);

header('location: index.php');

?>

You might also like