Anda di halaman 1dari 16

PROGRAMACIÓN DE SITIOS WEB

APORTE TRABAJO
Fase 4 - Manejo de bases de datos

Presentado por:
Sindy Yohana Rojas Celis, Código 1083877119

Presentado a:
Yhon Jerson Robles Puentes

Grupo:
301127_15

Universidad Nacional Abierta y a Distancia - UNAD


CCAV - Neiva
Mayo de 2015
DESARROLLO DE LA ACTIVIDAD

Crear una aplicación web que controle el acceso a las salas de informática de la
UNAD, en donde existen N salas de computo, cada persona que acceso a la sala debe tener
en el sistema (Cedula, nombres, apellidos, sexo, ciudad, departamento), si es estudiante,
profesor o visitante, cuando va a ingresar a la sala la persona da su cedula y si existe en el
sistema le dice a qué sala va a ingresar, sino existe en el sistema, se le solicitaran los datos
para ingresarlo al sistema, cuando salga de la sala se dará salida del sistema.

Se debe generar informes sobre que asistentes fueron a las salas, por sala,
estudiantes que visitaron las salas, los visitantes que fueron a las salas, visitas que han
hecho un estudiante especifico, estos informes son en PDF. También se debe tener un
administrador del sistema que genere los informes y que cree las salas de sistemas, también
él puede generar la copia de seguridad del sistema

RESPUESTA:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"


"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"
/>
<center><h2> UNAD- PROGRAMACION DE SITIOS WEB 2015 </h2>
programcion php <br>
Ejercicio colaborativo 3 <br>
</center>

<title>usuarios</title>
</head>

<?php
$mysqli=new mysqli("localhost","root","Fiscaliza13","sistema");

if(mysquli_connect_erno()){
echo'Conexion Falla:', mysquli_connect_error();
}
?>
<body>
</body>
</html>
<?php
requiere('conexion.php')

$query="SELECT cedula, nombres, apellidos, sexo, ciudad,


departamento, rol en la institucion FROM usuarios";

$resultado=$mysqli->query($query)

?>

html
<head>

<html>
<head>
</head>
<body>
<center><h2> UNAD- PROGRAMACION DE SITIOS WEB 2015 </h2>
programcion php <br>
Ejercicio colaborativo 3 <br>
</center>

<title></title>
</head>
<body>
<center><h1>Datos de Usuarios sala informatica UNAD</h1></center>

<a href="nuevo.php">Nuevo usuario</a>


<p></p>

<p>&nbsp;</p>
<table width="377" border="1">
<tr>
<td width="22" bgcolor="#CCCCCC">Cédula</td>
<td width="22" bgcolor="#CCCCCC">Nombres</td>
<td width="22" bgcolor="#CCCCCC">Apellidos</td>
<td width="22" bgcolor="#CCCCCC">Sexo</td>
<td width="22" bgcolor="#CCCCCC">Ciudad </td>
<td width="22" bgcolor="#CCCCCC">Departamento</td>

</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>

</tr>
</table>

<p>Debe elegir un rol </p>


<tbody>

<p>
<input type="checkbox" value="estudiante" name="countries[]" />
<label>Estudiante</label>
<br/>
<input type="checkbox" value="docente" name="countries[]" />
<label>Docennte</label>
<br/>
<input type="checkbox" value="funcionario" name="countries[]" />
<label>Funcionario</label>
<br/>
<input type="checkbox" value="visitante" name="countries[]" />
<label>Visitante</label>
<br/>
<input type="submit" name="enviar" value="enviar" />
</p>
<p>

<?php
if (isset($_POST['enviar'])) {
if (is_array($_POST['countries'])) {
$selected = '';
$num_countries = count($_POST['countries']);
$current = 0;
foreach ($_POST['countries'] as $key => $value) {
if ($current != $num_countries-1)
$selected .= $value.', ';
else
$selected .= $value.'.';
$current++;
}
}
else {
$selected = 'debes elegir un rol';
}

echo '<div>Has seleccionado: '.$selected.'</div>';


}
?>
<?php
while($row=$resultado->fetch_assoc())}{
?>
</p>
<tr>
<td><?php echo $row['cedula'];?>
<tr>
<td><?php echo $row['Nombres'];?>
</td>
<td><?php echo $row['Apellidos'];?>
</td>
<td><?php echo $row['sexo'];?>
</td>
<tr>
<td><?php echo $row['ciudad'];?>
</td>
<tr>
<td><?php echo $row['departamento'];?>
</td>
<tr>
<td><?php echo $row['rol en la institucion'];?>
</td>
<a href=modificar.php?codigo=<?php echo
$row['Codigo'];?>">Modificar</a>
</td>
<a href=eliminar.php?codigo=<?php echo
$row['Codigo'];?>">Eliminar</a>
</td>
<?php} ?>
</tr>
</table>
<p>&nbsp;</p>
</body>
</html>

<html>
<head>
<title>Usuarios</title>
</head>
<body>

<body>
<center><h2> UNAD- PROGRAMACION DE SITIOS WEB 2015 </h2>
programcion php <br>
Ejercicio trabajo colaborativo 3 <br>
</center>
<center>
<h1>Nuevo Usuario de la sala de informática
UNAD</h1></center>

<form name="nuevo_usuario" method="POST"


action="guarda_usuario.php">
<table width="50%">
<tr>
<td width="20"><b>Cédula</b></td>
<td width="30"><input type="text"
name="usuario" size="25" /></td>
</tr>
<tr>
<td><b>Nombres</b></td>
<td><input type="nombre" name="Nombres"
size="25" /></td>
</tr>
<tr>
<td><b>Apellidos</b></td>
<td><input type="text" name="apellidos"
size="25" /></td>
</tr>
<tr>
<td><b>Sexo</b></td>
<td><input type="text" name="sexo"
size="25" /></td>
</tr>
<tr>
<td><b>Ciudad</b></td>
<td><input type="text" name="ciudad"
size="25" /></td>
</tr>
<tr>
<td><b>Departamento</b></td>
<td><input type="text"
name="departamento" size="25" /></td>
</tr>

<td colspan="2"><center>
<p>Debe elegir un rol </p>
<p>
<input type="checkbox" value="estudiante"
name="countries[]" />
<label>Estudiante</label>
<br/>
<input type="checkbox" value="docente"
name="countries[]" />
<label>Docennte</label>
<br/>
<input type="checkbox" value="funcionario"
name="countries[]" />
<label>Funcionario</label>
<br/>
<input type="checkbox" value="visitante"
name="countries[]" />
<label>Visitante</label>
</p>
<p>
<input type="submit" name="eviar"
value="Registrar" />
</p>
</center></td>
</tr>
</table>
</form>
</body>

<body>
</body>
</html>

<html>
<head>
</head>
<body>
<center><h2> UNAD- PROGRAMACION DE SITIOS WEB 2015 </h2>
programcion php <br>
Ejercicio trabajo colaborativo 3 <br>
</center>

<?php

require('conexion.php');

$codigo=$_POST['Código'];
$nombres=$_POST['Nombres'];
$apellidos=$_POST['Apellidos'];
$Edad=$_POST['Edad'];

$query="INSERT INTO usuarios (codigo, nombres, apellidos,


edad) VALUES ('$codigo','$nombres','$apellidos','$edad')";

$resultado=$mysqli->query($query);

?>

<html>
<head>
<title>Guardar usuario</title>
<body>
<center>

<?php if($resultado>0){ ?>


<h1>Usuario Nuevo Guardado</h1>
<?php }else{ ?>
<h1>Error al Guardar Usuario Nuevo</h1>

<?php } ?>

<p></p>

<a href="index.php">Regresar</a>

</center>
</body>
</html>

<?php

require('conexion.php');

$id=$_GET['id'];

$query="SELECT cedula, nombres, apellidos, sexo, ciudad,


departamento, rol en la institucion FROM usuarios WHERE id='$id'";

$resultado=$mysqli->query($query);

$row=$resultado->fetch_assoc();

?>

<html>
<head>
<title>Usuarios</title>
</head>
<body>

<html>
<head>
<body>
<center><h2> UNAD- PROGRAMACION DE SITIOS WEB 2015 </h2>
programcion php <br>
Ejercicio trabajo colaborativo 3 <br>
</center>
<center>
<h1>Modificar Usuario Nuevo de la sala de informatica
UNAD</h1></center>

<form name="modificar_usuario" method="POST"


action="mod_usuario.php">

<table width="50%">
<tr>
<input type="hidden" name="id"
value="<?php echo $id; ?>">
<td width="20"><b>Cédula</b></td>
<td width="30"><input type="text"
name="cedula" size="25" value="<?php echo $row['usuario']; ?>"
/></td>
</tr>
<tr>
<td><b>Nombres</b></td>
<td><input type="nombres" name="nombres"
size="25" value="<?php echo $row['nombre']; ?>" /></td>
</tr>
<tr>
<td><b>Apellidos</b></td>
<td><input type="text" name="apellidos"
size="25" value="<?php echo $row['apellidos']; ?>" /></td>
</tr>
<tr>
<td><b>Sexo</b></td>
<td><input type="text" name="sexo"
size="25" value="<?php echo $row['sexo']; ?>" /></td>
</tr>
<tr>
<td><b>Ciudad</b></td>
<td><input type="text" name="ciudad"
size="25" value="<?php echo $row['ciudad']; ?>" /></td>
</tr> <tr>
<td><b>Departamento</b></td>
<td><input type="text"
name="departamento" size="25" value="<?php echo
$row['departamento']; ?>" /></td>
</tr>
<tr>
<td><b>Rol en la Insitucion</b></td>
<td><input type="text" name="rol en la
institucion" size="25" value="<?php echo $row['rol en la
institucion']; ?>" /></td>
</tr><tr>
<td colspan="2"><center>
<p>Debe elegir un rol </p>
<p>
<input type="checkbox" value="estudiante"
name="countries[]" />
<label>Estudiante</label>
<br/>
<input type="checkbox" value="docente"
name="countries[]" />
<label>Docennte</label>
<br/>
<input type="checkbox" value="funcionario"
name="countries[]" />
<label>Funcionario</label>
<br/>
<input type="checkbox" value="visitante"
name="countries[]" />
<label>Visitante</label>
</p>
<p>
<input type="submit" name="Guardar"
value="Guardar" />
</p>
</center></td>
</tr>
</table>
<p>&nbsp;</p>
<p><br/>
</p>
</form>
</body>
</html>

<html>
<head>
</head>
<body>
<center><h2> UNAD- PROGRAMACION DE SITIOS WEB 2015 </h2>
programcion php <br>
Ejercicio trabajo colaborativo 3 <br>
</center>

<?php

require('conexion.php');

$codigo=$_POST['codigo'];
$nombres=$_POST['nombres'];
$apellidos=$_POST['apellidos'];
$edad=$_POST['edad'];
$query="UPDATE usuarios SET cedula='$cedula',
nombres='$nombres', apellidos='$apellidos', sexo='$sexo',
ciudad='$ciudad', departamento='$departamento', rol en la
institucion='$rol en la institucion' WHERE codigo='$codigo'";

$resultado=$mysqli->query($query);

?>

<html>
<head>
<title>Modificar usuario</title>

<body>
<center>

<?php
if($resultado>0){
?>

<h1>Usuario Nuevo Modificado</h1>

<?php }else{ ?>

<h1>Error al Modificar Usuario Nuevo</h1>

<?php } ?>

<p></p>

<a href="index.php">Regresar</a>

</center>
</body>
</html>

<html>
<head>
</head>
<body>
<center><h2> UNAD- PROGRAMACION DE SITIOS WEB 2015 </h2>
programcion php <br>
Ejercicio trabajo colaborativo 3 <br>
</center>

<?php

require('conexion.php');
$id=$_GET['codigo'];

$query="DELETE FROM usuarios WHERE codigo='$codigo'";

$resultado=$mysqli->query($query);

?>

<html>
<head>
<title>Eliminar usuario</title>

<body>
<center>
<?php
if($resultado>0){
?>

<h1>Usuario Nuevo Eliminado</h1>

<?php }else{ ?>

<h1>Error al Eliminar Usuario Nuevo</h1>

<?php } ?>
<p></p>

<a href="index.php">Regresar</a>

</center>
</body>
</html>

<html>
<head>
</head>
<body>
<center><h2> UNAD- PROGRAMACION DE SITIOS WEB 2015 </h2>
programcion php <br>
Ejercicio trabajo colaborativo 3 <br>
</center>

<?php

require('conexion.php');

$id=$_GET['codigo'];

$query="DELETE FROM usuarios WHERE codigo='$codigo'";


$resultado=$mysqli->query($query);

?>

<html>
<head>
<title>Eliminar usuario</title>

<body>
<center>
<?php
if($resultado>0){
?>

<h1>Usuario Nuevo Eliminado</h1>

<?php }else{ ?>

<h1>Error al Eliminar Usuario Nuevo</h1>

<?php } ?>
<p></p>

<a href="index.php">Regresar</a>

</center>
</body>
</html>

<html>
<head>
</head>
<body>
<center><h2> UNAD- PROGRAMACION DE SITIOS WEB 2015 </h2>
programcion php <br>
Ejercicio colaborativo 3 <br>
</center>
<?php
requiere_once("dompsdf/dompdf_config.inc.php");
$conexion= mysql_connect("localhost","root","");
mysql_select_db("trabajo3",$conexion);

$codigoHTML='
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"
/>
<title>Lista</title>
</head>

<body>
<div aling="center">
<table width="200" border="1">
<tr>
<td bgcolor="#999999"><strong>Cédula</strong></td>
<td bgcolor="#999999"><strong>Nombres</strong></td>
<td bgcolor="#999999"><strong>Apellidos</strong></td>
<td bgcolor="#999999"><strong>Sexo</strong></td>
<td bgcolor="#999999"><strong>Ciudad</strong></td>
<td
bgcolor="#999999"><strong>Departamento</strong></td>
</tr>';

$consulta==mysql_query("SELECT * FROM usuarios");


while($dato=mysql_fetch_array($consulta)){
$codigoHTML.='
<tr>
<td>'.$dato['cedula'].'</td>
<td>'.$dato['nombres'].'</td>
<td>'.$dato['apellidos'].'</td>
<td>'.$dato['sexo'].'</td>
<td>'.$dato['ciudad'].'</td>
<td>'.$dato['departamento'].'</td>
</tr>
}
$codigoHTML.='
</table>
</div>
</body>
</html>';
echo $codigoHTML;

$codigoHTML=utf8_decode($codigoHTML);
$dompdf=new DOMPDF();
$dompdf->load_html($codigoHTML);
ini_set("memory_limit","128M");
$dompdf->render();
$dompdf->stream("Lista de Usuarios Sala de Informática
UNAD.pdf");
?>

<html>
<head>
</head>
<body>
<center><h2> UNAD- PROGRAMACION DE SITIOS WEB 2015 </h2>
programcion php <br>
Ejercicio colaborativo 3 <br>
</center>

<?php
$conexion = mysql_connect("localhost","root","");
mysql_select_db("tarea",$conexion);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"
/>
<body>
<h1 align="center"><a href="lista.php" title="Reporte de
Empleados">Lista de Usuarios Sala de Informática UNAD</a></h1>
</body>
</html>
REFERENCIAS BIBLIOGRÁFICAS

Cómo Listar, añadir, editar y borrar records de una tabla con PHP y Dreamweaver.
Consultado en https://www.youtube.com/watch?v=ieeRfZEFOAc

Curso PHP orientado a Objetos - como crear una tabla y sus campos desde el código.
Consultado en https://www.youtube.com/watch?v=M4ri9LmVv7w

Curso PHP orientado a Objetos - como crear una tabla y campos desde una clase 2.
Consultado en https://www.youtube.com/watch?v=Rn8vLnyMypU

Diseño de base de datos. Consultado en


http://php.net/manual/es/security.database.design.php

Insertar, Actualizar, Eliminar, Busca PHP y MySQL. Consultado de


https://www.youtube.com/watch?v=jbP4ndpepOo

Php y Base de Datos. Consultado en http://www.htmlpoint.com/php/php_10.htm

Reporte en PDF con PHP/phpMyAdmin. Recuperado de


https://www.youtube.com/watch?v=c9twV7jkjJg

Anda mungkin juga menyukai