Professional Documents
Culture Documents
Modificar-Agregar-Eliminar PHP
Modificar-Agregar-Eliminar PHP
php
<!DOCTYPE html>
<html>
<head>
<style type="text/css">
@import url("css/mycss.css");
</style>
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body>
<div class="todo">
<div id="cabecera">
</div>
<div id="contenido">
<table style="margin: auto; width: 800px; border-collapse: separate; border-spacing: 10px 5px;">
<thead>
<th>No.</th>
<th>ID</th>
<th>Producto</th>
<th>Descripcion</th>
</thead>
<?php
include "conexion.php";
$resultado=mysql_query($sentencia);
while($filas=mysql_fetch_assoc($resultado))
echo "<tr>";
echo "</tr>";
?>
</table>
</div>
<div id="footer">
</div>
</div>
</body>
</html>
Conexión.php
<?php
$conexion = mysql_connect("localhost","usuario","usuario");
mysql_select_db("mi_negocio",$conexion);
//date_default_timezone_set("America/Mexico");
/*
function limpiar($tags){
$tags = strip_tags($tags);
$tags = stripslashes($tags);
$tags = htmlentities($tags);
$tags = mysql_real_escape_string($tags);
return $tags;
*/
?>
Nuevo_prod1.php
<?php
include "conexion.php";
?>
<!DOCTYPE html>
<html>
<head>
<title>Alta de Producto</title>
<style type="text/css">
@import url("css/mycss.css");
</style>
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body>
<div class="todo">
<div id="cabecera">
</div>
<div id="contenido">
<div style="margin: auto; width: 800px; border-collapse: separate; border-spacing: 10px 5px;">
<br>
<label>Producto: </label>
<label>Descripcion: </label>
<br>
</form>
</div>
</div>
<div id="footer">
</div>
</div>
</body>
</html>
Nuevo_prod2.php
<?php
include 'conexion.php';
?>
<script type="text/javascript">
window.location.href='index.php';
</script>
Modif_prod1.php
<?php
include 'conexion.php';
$consulta=ConsultarProducto($_GET['no']);
function ConsultarProducto($no_prod)
$filas=mysql_fetch_assoc($resultado);
return [
$filas['id_producto'],
$filas['nombre'],
$filas['descripcion']
];
?>
<!DOCTYPE html>
<html>
<head>
<title>Modificar Producto</title>
<style type="text/css">
@import url("css/mycss.css");
</style>
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body>
<div class="todo">
<div id="cabecera">
</div>
<div id="contenido">
<div style="margin: auto; width: 800px; border-collapse: separate; border-spacing: 10px 5px;">
<br>
<label>Producto: </label>
<label>Descripcion: </label>
<textarea style="border-radius: 10px;" rows="3" cols="50" name="descripcion"> <?php echo
$consulta[2] ?> </textarea><br>
<br>
</form>
</div>
</div>
<div id="footer">
</div>
</div>
</body>
</html>
Modif_prod2.php
<?php
include 'conexion.php';
ModificarProducto($_POST['id_producto'], $_POST['producto'], $_POST['descripcion'], $_POST['no']);
?>
<script type="text/javascript">
window.location.href='index.php';
</script>
Eliminar_prod.php
<?php
include "conexion.php";
EliminarProducto($_GET['no']);
function EliminarProducto($no)
?>
<script type="text/javascript">
window.location.href='index.php';
</script>