UNIVERSIDAD CENTRAL DEL ECUADOR
F FACULTAD DE FILOSOFÍA, LETRAS Y CIENCIAS DE LA EDUCACIÓN
PEDAGOGÍA DE LAS CIENCIAS EXPERIMENTALES DE LA
INFORMÁTICA
PROGRAMACIÓN ORIENTADA A OBJETOS
AUTOR:
Mateo Quishpe
PARALELO:
3 “C”
DOCENTE:
MSc. Víctor Zapata
FECHA:
22 – 09 – 2021
INFORME DEL EXAMEN
TEMA:
Examen
OBJETIVO:
Usar todo lo aprendido a lo largo del semestre en un programa alternativo
RESULTADOS DE APRENDIZAJE
Comprender todas las sentencias aprendidas
Desarrollar un proyecto propio
ACTIVIDADES:
- Elaborar un programa alternativo
- Pagina de compra de pizzas
DESARROLLO DE CONTENIDOS
CODIGO DEL PROGRAMA:
<?php
$host="localhost";
$bd= "proyectoe";
$usuario="root";
$contrasenia="";
try {
$conexion=new PDO("mysql:host=$host;dbname=$bd", $usuario, $contras
enia);
} catch ( Exception $ex) {
echo $ex->getMessage();
}
?>
<?php
session_start();
session_destroy();
header('Location: ../index.php');
?>
<?php
$conex = mysqli_connect("localhost","root","","proyectoe");
?>
* {
padding: 0;
margin: 0;
font-family: century gothic;
color: #444
}
h1 {
padding: 12px;
}
div {
padding: 10px 20px;
}
<?php
$inc = include("con_db.php");
?>
<?php
if ($inc) {
$consulta = "SELECT * FROM productos";
$resultado = mysqli_query($conex,$consulta);
if ($resultado) {
$u=1;
while ($row = $resultado->fetch_array()) {
$id = $row['id'];
$nombre = $row['nombre'];
$imagen = $row['imagen'];
$precio = $row['precio'];
$descripcion = $row['descripcion'];
?>
<div>
<div>
<p>
<?php print 'Registro: '.$u;?>
<b><br> ID: </b> <?php echo $id ?><br>
<b>NOMBRE: </b> <?php echo $nombre ?><br>
<b>IMAGEN: </b> <?php echo $imagen ?><br>
<b>PRECIO: </b> <?php echo $precio ?><br>
<b>DESCRIPCION: </b> <?php echo $descripcion ?><br
>
</p>
</div>
</div>
<?php
$u=$u+1;
}
}
}
?>
<?php include("../template/cabecera.php"); ?>
<?php
$txtID=(isset($_POST['txtID']))?$_POST['txtID']:"";
$txtNombre=(isset($_POST['txtNombre']))?$_POST['txtNombre']:"";
$txtImagen=(isset($_FILES['txtImagen']['name']))?$_FILES['txtImagen
']['name']:"";
$txtPrecio=(isset($_POST['txtPrecio']))?$_POST['txtPrecio']:"";
$txtDescripcion=(isset($_POST['txtDescripcion']))?$_POST['txtDescri
pcion']:"";
$accion=(isset($_POST['accion']))?$_POST['accion']:"";
include("../config/bd.php");
switch($accion){
case "Agregar":
$sentenciaSQL= $conexion-
>prepare("INSERT INTO productos (nombre, imagen, precio, descripcion) V
ALUES (:nombre,:imagen,:precio,:descripcion);");
$sentenciaSQL->bindParam(':nombre',$txtNombre);
$fecha= new DateTime();
$nombreArchivo=($txtImagen!="")?$fecha-
>getTimestamp()."_".$_FILES["txtImagen"]['name']:"imagen.jpg";
$tmpImagen=$_FILES["txtImagen"]["tmp_name"];
if ($tmpImagen!="") {
move_uploaded_file($tmpImagen,"../../img/".$nombreArchi
vo);
}
$sentenciaSQL->bindParam(':imagen',$nombreArchivo);
$sentenciaSQL->bindParam(':precio',$txtPrecio);
$sentenciaSQL->bindParam(':descripcion',$txtDescripcion);
$sentenciaSQL->execute();
break;
case "Modificar":
echo "Presionado botón Modificar";
$sentenciaSQL= $conexion-
>prepare("UPDATE productos SET nombre=:nombre WHERE id=:id");
$sentenciaSQL->bindParam(':nombre',$txtNombre);
$sentenciaSQL->bindParam(':id',$txtID);
$sentenciaSQL->execute();
$sentenciaSQL= $conexion-
>prepare("UPDATE productos SET precio=:precio WHERE id=:id");
$sentenciaSQL->bindParam(':precio',$txtPrecio);
$sentenciaSQL->bindParam(':id',$txtID);
$sentenciaSQL->execute();
$sentenciaSQL= $conexion-
>prepare("UPDATE productos SET descripcion=:descripcion WHERE id=:id");
$sentenciaSQL->bindParam(':descripcion',$txtDescripcion);
$sentenciaSQL->bindParam(':id',$txtID);
$sentenciaSQL->execute();
if ($txtImagen!="") {
$fecha= new DateTime();
$nombreArchivo=($txtImagen!="")?$fecha-
>getTimestamp()."_".$_FILES["txtImagen"]['name']:"imagen.jpg";
$tmpImagen=$_FILES["txtImagen"]["tmp_name"];
move_uploaded_file($tmpImagen,"../../img/".$nombreArchi
vo);
$sentenciaSQL= $conexion-
>prepare("SELECT imagen FROM productos WHERE id=:id");
$sentenciaSQL->bindParam(':id',$txtID);
$sentenciaSQL->execute();
$producto=$sentenciaSQL->fetch(PDO::FETCH_LAZY);
if ( isset($producto["imagen"]) &&($producto["imagen"]!="im
agen.jpg") ) {
if (file_exists("../../img/".$producto["imagen"])) {
unlink("../../img/".$producto["imagen"]);
}
}
$sentenciaSQL= $conexion-
>prepare("UPDATE productos SET imagen=:imagen WHERE id=:id");
$sentenciaSQL->bindParam(':imagen',$nombreArchivo);
$sentenciaSQL->bindParam(':id',$txtID);
$sentenciaSQL->execute();
}
header("Location: productos.php");
break;
case "Cancelar":
header("Location: productos.php");
break;
case "Seleccionar":
//busqueda e impresion de datos";
$sentenciaSQL= $conexion-
>prepare("SELECT * FROM productos WHERE id=:id");
$sentenciaSQL->bindParam(':id',$txtID);
$sentenciaSQL->execute();
$producto=$sentenciaSQL->fetch(PDO::FETCH_LAZY);
$txtNombre=$producto['nombre'];
$txtImagen=$producto['imagen'];
$txtPrecio=$producto['precio'];
$txtDescripcion=$producto['descripcion'];
break;
case "Borrar":
$sentenciaSQL= $conexion-
>prepare("SELECT imagen FROM productos WHERE id=:id");
$sentenciaSQL->bindParam(':id',$txtID);
$sentenciaSQL->execute();
$producto=$sentenciaSQL->fetch(PDO::FETCH_LAZY);
if ( isset($producto["imagen"]) &&($producto["imagen"]!="im
agen.jpg") ) {
if (file_exists("../../img/".$producto["imagen"])) {
unlink("../../img/".$producto["imagen"]);
}
}
$sentenciaSQL= $conexion-
>prepare("DELETE FROM productos WHERE id=:id");
$sentenciaSQL-> bindParam(':id', $txtID);
$sentenciaSQL->execute();
header("Location: productos.php");
break;
}
$sentenciaSQL= $conexion->prepare("SELECT * FROM productos ");
$sentenciaSQL->execute();
$listaproductos=$sentenciaSQL->fetchAll(PDO::FETCH_ASSOC);
?>
<div class="col-md-5">
<div class="card">
<div class="card-header">
<center>
<h4 style="color: red;">PRODUCTOS A INSERTAR </h4>
</center>
</div>
<div class="card-body">
<form method="POST" enctype="multipart/form-data">
<div class = "form-group">
<label for="txtID">ID:</label>
<input type="text" required readonly class="form-
control" value="<?php echo $txtID; ?>" name="txtID" id="txtID" placehol
der="ID">
</div>
<div class = "form-group">
<label for="txtNombre">Nombre del producto:</label>
<input type="text" required class="form-
control" value="<?php echo $txtNombre; ?>" name="txtNombre" id="txtNomb
re" placeholder="Nombre">
</div>
<div class = "form-group">
<label for="txtNombre">Imagen del producto:</label>
<br>
<?php if ($txtImagen!="") { ?>
<img class="img-
thumbnail rounded" src="../../img/<?php echo $txtImagen; ?>" width="50"
alt="">
<?php } ?>
<input type="file" class="form-
control" name="txtImagen" id="txtImagen" placeholder="Nombre">
</div>
<div class = "form-group">
<label for="txtPrecio">Precio del producto:</label>
<input type="text" required class="form-
control" value="<?php echo $txtPrecio; ?>" name="txtPrecio" id="txtPrec
io" >
</div>
<div class = "form-group">
<label for="txtDescripcion">Descripcion del product
o:</label>
<input type="text" required class="form-
control" value="<?php echo $txtDescripcion; ?>" name="txtDescripcion" i
d="txtDescripcion" placeholder="Descripcion">
</div>
<div class="btn-group" role="group" aria-label="">
<button type="submit" name="accion" <?php echo ($ac
cion == "Seleccionar")?"disabled":""; ?> value="Agregar" class="btn btn
-success">Agregar</button>
<button type="submit" name="accion" <?php echo ($ac
cion != "Seleccionar")?"disabled":""; ?> value="Modificar" class="btn b
tn-warning">Modificar</button>
<button type="submit" name="accion" <?php echo ($ac
cion != "Seleccionar")?"disabled":""; ?> value="Cancelar" class="btn bt
n-info">Cancelar</button>
</div>
</form>
</div>
</div>
</div>
<div class="col-md-7">
<table class="table table-bordered">
<thead>
<tr>
<th>ID</th>
<th>Nombre de la pizza</th>
<th>Imagen del producto</th>
<th>Precio del producto</th>
<th>Descripcion del producto</th>
<th>Acciones a realizar</th>
</tr>
</thead>
<tbody>
<?php
foreach($listaproductos as $producto){ ?>
<tr>
<td><?php echo $producto['id']; ?></td>
<td><?php echo $producto['nombre']; ?></td>
<td>
<img class="img-
thumbnail rounded" src="../../img/<?php echo $producto['imagen']; ?>" w
idth="50" alt="">
</td>
<td><?php echo $producto['precio']; ?></td>
<td><?php echo $producto['descripcion']; ?></td>
<td>
<form method="POST">
<input type="hidden" name="txtID" id="txtID" va
lue="<?php echo $producto['id']; ?>">
<input type="submit" name="accion" value="Selec
cionar" class="btn btn-primary"/>
<input type="submit" name="accion" value="Borra
r" class="btn btn-danger"/>
</form>
</td>
</tr>
<?php } ?>
</tbody>
</table>
</div>
<?php include("../template/pie.php"); ?>
<?php include("../template/cabecera.php"); ?>
<head>
<title>Registrar usuario</title>
<meta charset="utf-8">
<link rel="stylesheet" type="text/css" href="estilo.css">
</head>
<body>
<?php
include("mostrar.php");
?>
</body>
<?php include("../template/pie.php"); ?>
<?php
session_start();
if($_POST){
if(($_POST['usuario']=="Mateo")&&($_POST['contrasenia']=="45613")){
$_SESSION['usuario']="ok";
$_SESSION['nombreUsuario']="PIZZERIA";
header('Location: inicio.php');
}else {
$mensaje="Error: El usuario o contraseña son incorrectos";
}
}
?>
<!doctype html>
<html lang="en">
<head>
<title>SESION-ADMIN</title>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-
scale=1, shrink-to-fit=no">
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/boo
tstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-
ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" cross
origin="anonymous">
</head>
<body background="../img/fondo11.jpg">
<div class="container">
<div class="row">
<div class="col-md-4">
</div>
<div class="col-md-4">
<br><br><br>
<div class="card">
<div class="card-header">
<center>
Login
</center>
</div>
<div class="card-body">
<?php
if (isset($mensaje)) { ?>
<div class="alert alert-danger" role="alert">
<?php echo $mensaje; ?>
</div>
<?php } ?>
<form method="POST">
<div class = "form-group">
<label>Usuario</label>
<input type="text" class="form-
control" name="usuario" placeholder="Escribe tu usuario">
</div>
<div class="form-group">
<label>Contraseña:</label>
<input type="password" class="form-
control" name="contrasenia" placeholder="Escribe tu contraseña">
</div>
<button type="submit" class="btn btn-
primary">Entrar al administrdor</button>
</form>
</div>
</div>
</div>
</div>
</div>
</body>
</html>
<?php include('template/cabecera.php');?>
<div class="col-md-12">
<div class="jumbotron">
<center>
<h1 class="display-
3">BIENVENIDO <?php echo $nombreUsuario; ?> </h1>
<p class="lead">Usted podra agregar, editar y borra
r los productos que quiere mostrar en su pagina web</p>
<hr class="my-2">
<img src="../img/img1.jfif" alt="">
</center>
<p class="lead">
<center>
<a class="btn btn-primary btn-
lg" href="seccion/productos.php" role="button">Administrar productos</a
>
</center>
</p>
</div>
</div>
<?php include('template/pie.php');?>
/* General */
body {
margin: 0;
padding: 0;
font-family: 'Roboto', sans-serif;
text-align: center;
}
/* Input Forms*/
input[type="text"], input[type="password"]{
outline: none;
padding: 20px;
display: block;
width: 300px;
border-radius: 3px;
border: 1px solid #eee;
margin: 20px auto;
}
input[type="submit"] {
padding: 10px;
color: #fff;
background: #0098cb;
width: 320px;
margin: 20px auto;
margin-top: 0;
border: 0;
border-radius: 3px;
cursor: pointer;
}
input[type="submit"]:hover {
background-color: #00b8eb;
}
/* Header */
header {
border-bottom: 2px solid #eee;
padding: 20px 0;
margin-bottom: 10px;
width: 100%;
text-align: center;
}
header a {
text-decoration: none;
color: #333;
}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Welcome to you WebApp</title>
<link href="https://fonts.googleapis.com/css?family=Roboto" rel="st
ylesheet">
<link rel="stylesheet" href="assets/css/style.css">
</head>
<body>
<header>
<a href="index.php"><font style="color:magenta;">PIZERIA MATEO</font>
</a>
</header>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-
scale=1.0" />
<title>Pizeria AC</title>
<link rel="stylesheet" href="estillob.css"/>
<!--FONT OSWALD-->
<link rel="preconnect" href="https://fonts.gstatic.com" />
<!--FONT AWESOME-->
<link
rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/font-
awesome/5.15.3/css/all.min.css"
/>
</head>
<body>
<?php require 'partials/header.php' ?>
<body>
<div class="menu-btn">
<i class="fas fa-bars"></i>
</div>
<div class="container">
<nav class="nav-main">
<img src="img/log.jpg" class="nav-brand" />
<ul class="nav-menu show">
<li>
<a href="index.php">INICIO</a>
</li>
<li>
<a href="informacion.php">INFORMACIÓN</a>
</li>
<li>
<a href="nosotros.php">QUIÉNES SOMOS</a>
</li>
<li>
<a href="productos.php">PIZZAS</a>
</li>
<li>
<a href="carritoCompras.php">OTROS PRODUCTOS</a>
</li>
<li>
<a href="ubicacion.php">UBICACIÓN</a>
</li>
</ul>
<ul class="nav-menu-right">
<li>
<a href="administrador/index.php">
<i class="fas fa-key"></i>
</a>
</li>
</ul>
</nav>
<hr class="my-2">
<br>
<hr class="my-2">
<section class="social">
<p>REDES SOCIALES</p>
<div class="links">
<a href="https://www.facebook.com">
<i class="fab fa-facebook-f" style="color: blue;"></i>
</a>
<a href="https://www.instagram.com">
<i class="fab fa-instagram" style="color: magenta;"></i>
</a>
<a href="https://wa.me/593992611164">
<i class="fab fa-whatsapp" style="color: black;"></i>
</a>
</div>
</section>
</div>
<script src="main.js"></script>
<hr class="my-2">
<center>
HECHO POR Mateo
</center>
<br>
</body>
</html>
<?php include("template/cabecera.php");?>
<?php
session_start();
$total=0;
echo "<h3>Carrito de compras</h3>";
if(isset($_SESSION["carrito"])){
foreach($_SESSION["carrito"] as $indice =>$arreglo){
echo "<hr>Producto: <strong> ".$indice."</strong><br>";
$total += $arreglo["cant"]*$arreglo["precio"];
foreach($arreglo as $key =>$value){
echo $key.": ".$value."<br>";
}
echo "<a href='carrito.php?item=$indice' style='color: blue
'>Eliminar Item</a>";
}
echo "<h3>El total de la compra actual es de: $total </h3>";
echo '<br><br><a href="carritoCompras.php" style="color: blue;"
>Regresar a Otros poductos</a><br>o<br>
<a href="productos.php" style="color: blue;">Regresar a Piz
zas</a><br><br>
<a href="carrito.php?vaciar=true" style="color: blue;">Vaci
ar carrito</a>';
}else{
echo "<script>alert('El carrito esta vacio')</script>";
?>
<a href="carritoCompras.php" style="color: blue;">Regressar a Otros
productos</a><br>o <br>
<a href="productos.php" style="color: blue;">Regressar a Pizzas</a>
<?php
}
if(isset($_REQUEST["vaciar"])){
session_destroy();
header("Location: carrito.php");
}
if(isset($_REQUEST["item"])){
$producto =$_REQUEST["item"];
unset($_SESSION["carrito"][$producto]);
echo "<script>alert('Se elimino el producto: $producto');</scri
pt>";
header("Location: carrito.php");
}
?>
<?php include("template/pie.php");?>
<?php
session_start();
?>
<?php include("template/cabecera.php");?>
<div align="center">
<h3>CARRITO</h3>
<a href="carrito.php"><img src="img/carrito.png" width="50px"></a>
<hr>
<table class="table table-dark" style="width: 600px;">
<h3>PRODUCTOS DEL AÑO</h3>
<thead>
<th>ID</th>
<th>NOMBRE</th>
<th>PRODUCTO</th>
<th>PRECIO</th>
<th>DESCRIPCIÓN</th>
<th>ACCIONES</th>
</thead>
<tbody>
<tr style="width: 600px;">
<td style="width: 100px;" align="center">1020</td>
<td style="width: 300px;" align="center">Coca - Cola</td>
<td style="width: 100px;">
<img src="img/fanta.jfif" width="100px" height="100px">
</td>
<td style="width: 300px;" align="center">
$ 0.75
</td>
<td style="width: 300px;" align="center">
Cola-cola lite, sabor fanta
</td>
<td style="width: 300px;" align="center">
<form action="carritoCompras.php" method="POST">
<input type="hidden" name="txtProducto" value="Coca-
Cola">
<input type="number" name="cant" value="1" style="width
: 50px;"><br>
<input type="hidden" name="txtPrecio" value="0.75">
<input type="submit" value="Agregar" name="btnAgregar">
</form>
</td>
</tr>
<tr style="width: 600px;">
<td style="width: 100px;" align="center">1021</td>
<td style="width: 300px;" align="center">Chetos</td>
<td style="width: 100px;">
<img src="img/chetos.jfif" width="100px" height="100px">
</td>
<td style="width: 300px;" align="center">
$ 1.75
</td>
<td style="width: 300px;" align="center">
Chetos de queso, picantes
</td>
<td style="width: 300px;" align="center">
<form action="carritoCompras.php" method="POST">
<input type="hidden" name="txtProducto" value="Chetos">
<input type="number" name="cant" value="1" style="width
: 50px;"><br>
<input type="hidden" name="txtPrecio" value="1.75">
<input type="submit" value="Agregar" name="btnAgregar">
</form>
</td>
</tr>
<tr style="width: 600px;">
<td style="width: 100px;" align="center">1022</td>
<td style="width: 300px;" align="center">Agua</td>
<td style="width: 100px;">
<img src="img/agua.jfif" width="100px" height="100px">
</td>
<td style="width: 300px;" align="center">
$ 1.00
</td>
<td style="width: 300px;" align="center">
Agua natural, Al clima
</td>
<td style="width: 300px;" align="center">
<form action="carritoCompras.php" method="POST">
<input type="hidden" name="txtProducto" value="Aguan">
<input type="number" name="cant" value="1" style="width
: 50px;"><br>
<input type="hidden" name="txtPrecio" value="1.00">
<input type="submit" value="Agregar" name="btnAgregar">
</form>
</td>
<tr style="width: 600px;">
<td style="width: 100px;" align="center">1023</td>
<td style="width: 300px;" align="center">Platanitos</td>
<td style="width: 100px;">
<img src="img/platanitos.jfif" width="100px" height="100px"
>
</td>
<td style="width: 300px;" align="center">
$ 0.75
</td>
<td style="width: 300px;" align="center">
Platanitos de limon
</td>
<td style="width: 300px;" align="center">
<form action="carritoCompras.php" method="POST">
<input type="hidden" name="txtProducto" value="Platanit
os">
<input type="number" name="cant" value="1" style="width
: 50px;"><br>
<input type="hidden" name="txtPrecio" value="0.75">
<input type="submit" value="Agregar" name="btnAgregar">
</form>
</td>
</tr>
<tr style="width: 600px;">
<td style="width: 100px;" align="center">1024</td>
<td style="width: 300px;" align="center">Doritos</td>
<td style="width: 100px;">
<img src="img/doritos.jfif" width="100px" height="100px">
</td>
<td style="width: 300px;" align="center">
$ 1.35
</td>
<td style="width: 300px;" align="center">
Doritos
</td>
<td style="width: 300px;" align="center">
<form action="carritoCompras.php" method="POST">
<input type="hidden" name="txtProducto" value="Doritos"
>
<input type="number" name="cant" value="1" style="width
: 50px;"><br>
<input type="hidden" name="txtPrecio" value="1.35">
<input type="submit" value="Agregar" name="btnAgregar">
</form>
</td>
</tr>
</tr>
</tbody>
</table>
</div>
<?php
if(isset($_REQUEST["btnAgregar"])){
$producto = $_REQUEST["txtProducto"];
$cantidad = $_REQUEST["cant"];
$precio = $_REQUEST["txtPrecio"];
$_SESSION["carrito"][$producto]["cant"]= $cantidad;
$_SESSION["carrito"][$producto]["precio"]= $precio;
echo "<script>alert('Producto $producto agregado con éxito al c
arrito de compras');</script>";
}
?>
<?php include("template/pie.php"); ?>
f.) _______ _______ f.) __________________
MSc. Víctor Zapata
ESTUDIANTE DOCENTE

Examen

  • 1.
    UNIVERSIDAD CENTRAL DELECUADOR F FACULTAD DE FILOSOFÍA, LETRAS Y CIENCIAS DE LA EDUCACIÓN PEDAGOGÍA DE LAS CIENCIAS EXPERIMENTALES DE LA INFORMÁTICA PROGRAMACIÓN ORIENTADA A OBJETOS AUTOR: Mateo Quishpe PARALELO: 3 “C” DOCENTE: MSc. Víctor Zapata FECHA: 22 – 09 – 2021
  • 2.
    INFORME DEL EXAMEN TEMA: Examen OBJETIVO: Usartodo lo aprendido a lo largo del semestre en un programa alternativo RESULTADOS DE APRENDIZAJE Comprender todas las sentencias aprendidas Desarrollar un proyecto propio ACTIVIDADES: - Elaborar un programa alternativo - Pagina de compra de pizzas DESARROLLO DE CONTENIDOS
  • 12.
    CODIGO DEL PROGRAMA: <?php $host="localhost"; $bd="proyectoe"; $usuario="root"; $contrasenia=""; try { $conexion=new PDO("mysql:host=$host;dbname=$bd", $usuario, $contras enia); } catch ( Exception $ex) {
  • 13.
    echo $ex->getMessage(); } ?> <?php session_start(); session_destroy(); header('Location: ../index.php'); ?> <?php $conex= mysqli_connect("localhost","root","","proyectoe"); ?> * { padding: 0; margin: 0; font-family: century gothic; color: #444 } h1 { padding: 12px; } div { padding: 10px 20px; } <?php $inc = include("con_db.php"); ?> <?php if ($inc) { $consulta = "SELECT * FROM productos"; $resultado = mysqli_query($conex,$consulta); if ($resultado) { $u=1; while ($row = $resultado->fetch_array()) { $id = $row['id']; $nombre = $row['nombre']; $imagen = $row['imagen']; $precio = $row['precio']; $descripcion = $row['descripcion'];
  • 14.
    ?> <div> <div> <p> <?php print 'Registro:'.$u;?> <b><br> ID: </b> <?php echo $id ?><br> <b>NOMBRE: </b> <?php echo $nombre ?><br> <b>IMAGEN: </b> <?php echo $imagen ?><br> <b>PRECIO: </b> <?php echo $precio ?><br> <b>DESCRIPCION: </b> <?php echo $descripcion ?><br > </p> </div> </div> <?php $u=$u+1; } } } ?> <?php include("../template/cabecera.php"); ?> <?php $txtID=(isset($_POST['txtID']))?$_POST['txtID']:""; $txtNombre=(isset($_POST['txtNombre']))?$_POST['txtNombre']:""; $txtImagen=(isset($_FILES['txtImagen']['name']))?$_FILES['txtImagen ']['name']:""; $txtPrecio=(isset($_POST['txtPrecio']))?$_POST['txtPrecio']:""; $txtDescripcion=(isset($_POST['txtDescripcion']))?$_POST['txtDescri pcion']:""; $accion=(isset($_POST['accion']))?$_POST['accion']:""; include("../config/bd.php"); switch($accion){ case "Agregar": $sentenciaSQL= $conexion- >prepare("INSERT INTO productos (nombre, imagen, precio, descripcion) V ALUES (:nombre,:imagen,:precio,:descripcion);"); $sentenciaSQL->bindParam(':nombre',$txtNombre); $fecha= new DateTime(); $nombreArchivo=($txtImagen!="")?$fecha- >getTimestamp()."_".$_FILES["txtImagen"]['name']:"imagen.jpg";
  • 15.
    $tmpImagen=$_FILES["txtImagen"]["tmp_name"]; if ($tmpImagen!="") { move_uploaded_file($tmpImagen,"../../img/".$nombreArchi vo); } $sentenciaSQL->bindParam(':imagen',$nombreArchivo); $sentenciaSQL->bindParam(':precio',$txtPrecio); $sentenciaSQL->bindParam(':descripcion',$txtDescripcion); $sentenciaSQL->execute(); break; case"Modificar": echo "Presionado botón Modificar"; $sentenciaSQL= $conexion- >prepare("UPDATE productos SET nombre=:nombre WHERE id=:id"); $sentenciaSQL->bindParam(':nombre',$txtNombre); $sentenciaSQL->bindParam(':id',$txtID); $sentenciaSQL->execute(); $sentenciaSQL= $conexion- >prepare("UPDATE productos SET precio=:precio WHERE id=:id"); $sentenciaSQL->bindParam(':precio',$txtPrecio); $sentenciaSQL->bindParam(':id',$txtID); $sentenciaSQL->execute(); $sentenciaSQL= $conexion- >prepare("UPDATE productos SET descripcion=:descripcion WHERE id=:id"); $sentenciaSQL->bindParam(':descripcion',$txtDescripcion); $sentenciaSQL->bindParam(':id',$txtID); $sentenciaSQL->execute(); if ($txtImagen!="") { $fecha= new DateTime(); $nombreArchivo=($txtImagen!="")?$fecha- >getTimestamp()."_".$_FILES["txtImagen"]['name']:"imagen.jpg"; $tmpImagen=$_FILES["txtImagen"]["tmp_name"]; move_uploaded_file($tmpImagen,"../../img/".$nombreArchi vo); $sentenciaSQL= $conexion- >prepare("SELECT imagen FROM productos WHERE id=:id"); $sentenciaSQL->bindParam(':id',$txtID); $sentenciaSQL->execute();
  • 16.
    $producto=$sentenciaSQL->fetch(PDO::FETCH_LAZY); if ( isset($producto["imagen"])&&($producto["imagen"]!="im agen.jpg") ) { if (file_exists("../../img/".$producto["imagen"])) { unlink("../../img/".$producto["imagen"]); } } $sentenciaSQL= $conexion- >prepare("UPDATE productos SET imagen=:imagen WHERE id=:id"); $sentenciaSQL->bindParam(':imagen',$nombreArchivo); $sentenciaSQL->bindParam(':id',$txtID); $sentenciaSQL->execute(); } header("Location: productos.php"); break; case "Cancelar": header("Location: productos.php"); break; case "Seleccionar": //busqueda e impresion de datos"; $sentenciaSQL= $conexion- >prepare("SELECT * FROM productos WHERE id=:id"); $sentenciaSQL->bindParam(':id',$txtID); $sentenciaSQL->execute(); $producto=$sentenciaSQL->fetch(PDO::FETCH_LAZY); $txtNombre=$producto['nombre']; $txtImagen=$producto['imagen']; $txtPrecio=$producto['precio']; $txtDescripcion=$producto['descripcion']; break; case "Borrar": $sentenciaSQL= $conexion- >prepare("SELECT imagen FROM productos WHERE id=:id"); $sentenciaSQL->bindParam(':id',$txtID); $sentenciaSQL->execute(); $producto=$sentenciaSQL->fetch(PDO::FETCH_LAZY); if ( isset($producto["imagen"]) &&($producto["imagen"]!="im agen.jpg") ) { if (file_exists("../../img/".$producto["imagen"])) { unlink("../../img/".$producto["imagen"]); }
  • 17.
    } $sentenciaSQL= $conexion- >prepare("DELETE FROMproductos WHERE id=:id"); $sentenciaSQL-> bindParam(':id', $txtID); $sentenciaSQL->execute(); header("Location: productos.php"); break; } $sentenciaSQL= $conexion->prepare("SELECT * FROM productos "); $sentenciaSQL->execute(); $listaproductos=$sentenciaSQL->fetchAll(PDO::FETCH_ASSOC); ?> <div class="col-md-5"> <div class="card"> <div class="card-header"> <center> <h4 style="color: red;">PRODUCTOS A INSERTAR </h4> </center> </div> <div class="card-body"> <form method="POST" enctype="multipart/form-data"> <div class = "form-group"> <label for="txtID">ID:</label> <input type="text" required readonly class="form- control" value="<?php echo $txtID; ?>" name="txtID" id="txtID" placehol der="ID"> </div> <div class = "form-group"> <label for="txtNombre">Nombre del producto:</label> <input type="text" required class="form- control" value="<?php echo $txtNombre; ?>" name="txtNombre" id="txtNomb re" placeholder="Nombre"> </div> <div class = "form-group"> <label for="txtNombre">Imagen del producto:</label> <br>
  • 18.
    <?php if ($txtImagen!=""){ ?> <img class="img- thumbnail rounded" src="../../img/<?php echo $txtImagen; ?>" width="50" alt=""> <?php } ?> <input type="file" class="form- control" name="txtImagen" id="txtImagen" placeholder="Nombre"> </div> <div class = "form-group"> <label for="txtPrecio">Precio del producto:</label> <input type="text" required class="form- control" value="<?php echo $txtPrecio; ?>" name="txtPrecio" id="txtPrec io" > </div> <div class = "form-group"> <label for="txtDescripcion">Descripcion del product o:</label> <input type="text" required class="form- control" value="<?php echo $txtDescripcion; ?>" name="txtDescripcion" i d="txtDescripcion" placeholder="Descripcion"> </div> <div class="btn-group" role="group" aria-label=""> <button type="submit" name="accion" <?php echo ($ac cion == "Seleccionar")?"disabled":""; ?> value="Agregar" class="btn btn -success">Agregar</button> <button type="submit" name="accion" <?php echo ($ac cion != "Seleccionar")?"disabled":""; ?> value="Modificar" class="btn b tn-warning">Modificar</button> <button type="submit" name="accion" <?php echo ($ac cion != "Seleccionar")?"disabled":""; ?> value="Cancelar" class="btn bt n-info">Cancelar</button> </div> </form> </div> </div> </div> <div class="col-md-7">
  • 19.
    <table class="table table-bordered"> <thead> <tr> <th>ID</th> <th>Nombrede la pizza</th> <th>Imagen del producto</th> <th>Precio del producto</th> <th>Descripcion del producto</th> <th>Acciones a realizar</th> </tr> </thead> <tbody> <?php foreach($listaproductos as $producto){ ?> <tr> <td><?php echo $producto['id']; ?></td> <td><?php echo $producto['nombre']; ?></td> <td> <img class="img- thumbnail rounded" src="../../img/<?php echo $producto['imagen']; ?>" w idth="50" alt=""> </td> <td><?php echo $producto['precio']; ?></td> <td><?php echo $producto['descripcion']; ?></td> <td> <form method="POST"> <input type="hidden" name="txtID" id="txtID" va lue="<?php echo $producto['id']; ?>"> <input type="submit" name="accion" value="Selec cionar" class="btn btn-primary"/> <input type="submit" name="accion" value="Borra r" class="btn btn-danger"/> </form> </td> </tr> <?php } ?> </tbody> </table> </div> <?php include("../template/pie.php"); ?> <?php include("../template/cabecera.php"); ?> <head> <title>Registrar usuario</title> <meta charset="utf-8"> <link rel="stylesheet" type="text/css" href="estilo.css"> </head>
  • 20.
    <body> <?php include("mostrar.php"); ?> </body> <?php include("../template/pie.php"); ?> <?php session_start(); if($_POST){ if(($_POST['usuario']=="Mateo")&&($_POST['contrasenia']=="45613")){ $_SESSION['usuario']="ok"; $_SESSION['nombreUsuario']="PIZZERIA"; header('Location:inicio.php'); }else { $mensaje="Error: El usuario o contraseña son incorrectos"; } } ?> <!doctype html> <html lang="en"> <head> <title>SESION-ADMIN</title> <!-- Required meta tags --> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial- scale=1, shrink-to-fit=no"> <!-- Bootstrap CSS --> <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/boo tstrap/4.3.1/css/bootstrap.min.css" integrity="sha384- ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" cross origin="anonymous"> </head> <body background="../img/fondo11.jpg"> <div class="container"> <div class="row"> <div class="col-md-4"> </div> <div class="col-md-4"> <br><br><br> <div class="card"> <div class="card-header">
  • 21.
    <center> Login </center> </div> <div class="card-body"> <?php if (isset($mensaje)){ ?> <div class="alert alert-danger" role="alert"> <?php echo $mensaje; ?> </div> <?php } ?> <form method="POST"> <div class = "form-group"> <label>Usuario</label> <input type="text" class="form- control" name="usuario" placeholder="Escribe tu usuario"> </div> <div class="form-group"> <label>Contraseña:</label> <input type="password" class="form- control" name="contrasenia" placeholder="Escribe tu contraseña"> </div> <button type="submit" class="btn btn- primary">Entrar al administrdor</button> </form> </div> </div> </div> </div> </div> </body> </html> <?php include('template/cabecera.php');?> <div class="col-md-12">
  • 22.
    <div class="jumbotron"> <center> <h1 class="display- 3">BIENVENIDO<?php echo $nombreUsuario; ?> </h1> <p class="lead">Usted podra agregar, editar y borra r los productos que quiere mostrar en su pagina web</p> <hr class="my-2"> <img src="../img/img1.jfif" alt=""> </center> <p class="lead"> <center> <a class="btn btn-primary btn- lg" href="seccion/productos.php" role="button">Administrar productos</a > </center> </p> </div> </div> <?php include('template/pie.php');?> /* General */ body { margin: 0; padding: 0; font-family: 'Roboto', sans-serif; text-align: center; } /* Input Forms*/ input[type="text"], input[type="password"]{ outline: none; padding: 20px; display: block; width: 300px; border-radius: 3px; border: 1px solid #eee; margin: 20px auto; } input[type="submit"] { padding: 10px; color: #fff; background: #0098cb; width: 320px; margin: 20px auto; margin-top: 0; border: 0; border-radius: 3px;
  • 23.
    cursor: pointer; } input[type="submit"]:hover { background-color:#00b8eb; } /* Header */ header { border-bottom: 2px solid #eee; padding: 20px 0; margin-bottom: 10px; width: 100%; text-align: center; } header a { text-decoration: none; color: #333; } <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>Welcome to you WebApp</title> <link href="https://fonts.googleapis.com/css?family=Roboto" rel="st ylesheet"> <link rel="stylesheet" href="assets/css/style.css"> </head> <body> <header> <a href="index.php"><font style="color:magenta;">PIZERIA MATEO</font> </a> </header> <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8" /> <meta http-equiv="X-UA-Compatible" content="IE=edge" /> <meta name="viewport" content="width=device-width, initial- scale=1.0" /> <title>Pizeria AC</title> <link rel="stylesheet" href="estillob.css"/> <!--FONT OSWALD--> <link rel="preconnect" href="https://fonts.gstatic.com" /> <!--FONT AWESOME--> <link rel="stylesheet"
  • 24.
    href="https://cdnjs.cloudflare.com/ajax/libs/font- awesome/5.15.3/css/all.min.css" /> </head> <body> <?php require 'partials/header.php'?> <body> <div class="menu-btn"> <i class="fas fa-bars"></i> </div> <div class="container"> <nav class="nav-main"> <img src="img/log.jpg" class="nav-brand" /> <ul class="nav-menu show"> <li> <a href="index.php">INICIO</a> </li> <li> <a href="informacion.php">INFORMACIÓN</a> </li> <li> <a href="nosotros.php">QUIÉNES SOMOS</a> </li> <li> <a href="productos.php">PIZZAS</a> </li> <li> <a href="carritoCompras.php">OTROS PRODUCTOS</a> </li> <li> <a href="ubicacion.php">UBICACIÓN</a> </li> </ul> <ul class="nav-menu-right"> <li> <a href="administrador/index.php"> <i class="fas fa-key"></i> </a> </li> </ul> </nav> <hr class="my-2"> <br> <hr class="my-2"> <section class="social"> <p>REDES SOCIALES</p> <div class="links"> <a href="https://www.facebook.com">
  • 25.
    <i class="fab fa-facebook-f"style="color: blue;"></i> </a> <a href="https://www.instagram.com"> <i class="fab fa-instagram" style="color: magenta;"></i> </a> <a href="https://wa.me/593992611164"> <i class="fab fa-whatsapp" style="color: black;"></i> </a> </div> </section> </div> <script src="main.js"></script> <hr class="my-2"> <center> HECHO POR Mateo </center> <br> </body> </html> <?php include("template/cabecera.php");?> <?php session_start(); $total=0; echo "<h3>Carrito de compras</h3>"; if(isset($_SESSION["carrito"])){ foreach($_SESSION["carrito"] as $indice =>$arreglo){ echo "<hr>Producto: <strong> ".$indice."</strong><br>"; $total += $arreglo["cant"]*$arreglo["precio"]; foreach($arreglo as $key =>$value){ echo $key.": ".$value."<br>"; } echo "<a href='carrito.php?item=$indice' style='color: blue '>Eliminar Item</a>"; } echo "<h3>El total de la compra actual es de: $total </h3>"; echo '<br><br><a href="carritoCompras.php" style="color: blue;" >Regresar a Otros poductos</a><br>o<br> <a href="productos.php" style="color: blue;">Regresar a Piz zas</a><br><br> <a href="carrito.php?vaciar=true" style="color: blue;">Vaci ar carrito</a>'; }else{
  • 26.
    echo "<script>alert('El carritoesta vacio')</script>"; ?> <a href="carritoCompras.php" style="color: blue;">Regressar a Otros productos</a><br>o <br> <a href="productos.php" style="color: blue;">Regressar a Pizzas</a> <?php } if(isset($_REQUEST["vaciar"])){ session_destroy(); header("Location: carrito.php"); } if(isset($_REQUEST["item"])){ $producto =$_REQUEST["item"]; unset($_SESSION["carrito"][$producto]); echo "<script>alert('Se elimino el producto: $producto');</scri pt>"; header("Location: carrito.php"); } ?> <?php include("template/pie.php");?> <?php session_start(); ?> <?php include("template/cabecera.php");?> <div align="center"> <h3>CARRITO</h3> <a href="carrito.php"><img src="img/carrito.png" width="50px"></a> <hr> <table class="table table-dark" style="width: 600px;"> <h3>PRODUCTOS DEL AÑO</h3> <thead> <th>ID</th> <th>NOMBRE</th> <th>PRODUCTO</th> <th>PRECIO</th> <th>DESCRIPCIÓN</th> <th>ACCIONES</th> </thead> <tbody> <tr style="width: 600px;"> <td style="width: 100px;" align="center">1020</td> <td style="width: 300px;" align="center">Coca - Cola</td> <td style="width: 100px;">
  • 27.
    <img src="img/fanta.jfif" width="100px"height="100px"> </td> <td style="width: 300px;" align="center"> $ 0.75 </td> <td style="width: 300px;" align="center"> Cola-cola lite, sabor fanta </td> <td style="width: 300px;" align="center"> <form action="carritoCompras.php" method="POST"> <input type="hidden" name="txtProducto" value="Coca- Cola"> <input type="number" name="cant" value="1" style="width : 50px;"><br> <input type="hidden" name="txtPrecio" value="0.75"> <input type="submit" value="Agregar" name="btnAgregar"> </form> </td> </tr> <tr style="width: 600px;"> <td style="width: 100px;" align="center">1021</td> <td style="width: 300px;" align="center">Chetos</td> <td style="width: 100px;"> <img src="img/chetos.jfif" width="100px" height="100px"> </td> <td style="width: 300px;" align="center"> $ 1.75 </td> <td style="width: 300px;" align="center"> Chetos de queso, picantes </td> <td style="width: 300px;" align="center"> <form action="carritoCompras.php" method="POST"> <input type="hidden" name="txtProducto" value="Chetos"> <input type="number" name="cant" value="1" style="width : 50px;"><br> <input type="hidden" name="txtPrecio" value="1.75"> <input type="submit" value="Agregar" name="btnAgregar"> </form> </td> </tr> <tr style="width: 600px;"> <td style="width: 100px;" align="center">1022</td> <td style="width: 300px;" align="center">Agua</td> <td style="width: 100px;"> <img src="img/agua.jfif" width="100px" height="100px"> </td> <td style="width: 300px;" align="center"> $ 1.00
  • 28.
    </td> <td style="width: 300px;"align="center"> Agua natural, Al clima </td> <td style="width: 300px;" align="center"> <form action="carritoCompras.php" method="POST"> <input type="hidden" name="txtProducto" value="Aguan"> <input type="number" name="cant" value="1" style="width : 50px;"><br> <input type="hidden" name="txtPrecio" value="1.00"> <input type="submit" value="Agregar" name="btnAgregar"> </form> </td> <tr style="width: 600px;"> <td style="width: 100px;" align="center">1023</td> <td style="width: 300px;" align="center">Platanitos</td> <td style="width: 100px;"> <img src="img/platanitos.jfif" width="100px" height="100px" > </td> <td style="width: 300px;" align="center"> $ 0.75 </td> <td style="width: 300px;" align="center"> Platanitos de limon </td> <td style="width: 300px;" align="center"> <form action="carritoCompras.php" method="POST"> <input type="hidden" name="txtProducto" value="Platanit os"> <input type="number" name="cant" value="1" style="width : 50px;"><br> <input type="hidden" name="txtPrecio" value="0.75"> <input type="submit" value="Agregar" name="btnAgregar"> </form> </td> </tr> <tr style="width: 600px;"> <td style="width: 100px;" align="center">1024</td> <td style="width: 300px;" align="center">Doritos</td> <td style="width: 100px;"> <img src="img/doritos.jfif" width="100px" height="100px"> </td> <td style="width: 300px;" align="center"> $ 1.35 </td> <td style="width: 300px;" align="center"> Doritos </td>
  • 29.
    <td style="width: 300px;"align="center"> <form action="carritoCompras.php" method="POST"> <input type="hidden" name="txtProducto" value="Doritos" > <input type="number" name="cant" value="1" style="width : 50px;"><br> <input type="hidden" name="txtPrecio" value="1.35"> <input type="submit" value="Agregar" name="btnAgregar"> </form> </td> </tr> </tr> </tbody> </table> </div> <?php if(isset($_REQUEST["btnAgregar"])){ $producto = $_REQUEST["txtProducto"]; $cantidad = $_REQUEST["cant"]; $precio = $_REQUEST["txtPrecio"]; $_SESSION["carrito"][$producto]["cant"]= $cantidad; $_SESSION["carrito"][$producto]["precio"]= $precio; echo "<script>alert('Producto $producto agregado con éxito al c arrito de compras');</script>"; } ?> <?php include("template/pie.php"); ?>
  • 30.
    f.) _______ _______f.) __________________ MSc. Víctor Zapata ESTUDIANTE DOCENTE