Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <head>
- <title>Insertar producto</title>
- <link rel="stylesheet" type="text/css" href="estilo.css" />
- </head>
- <?php
- include ("conexion.php");
- $Nombre_Producto=$_POST['Nombre_Producto'];
- $Imagen_Producto=$_POST['Imagen_Producto'];
- $Descripcion_Producto=$_POST['Descripcion_Producto'];
- $Precio_Producto=$_POST['Precio_Producto'];
- $ID_Categoria=$_POST['ID_Categoria'];
- $Stok_Producto=$_POST['Stok_Producto'];
- if ($Nombre_Producto != NULL/* && $Descripcion_Producto != NULL && $Precio_Producto != NULL && $Categoria_Producto != NULL && $Stok_Producto != NULL*/)
- {
- $productos = "INSERT INTO productos VALUES ('$ID_Producto',' ".$Nombre_Producto." ',' ".$Imagen_Producto." ',' ".$Descripcion_Producto." ',' ".$Precio_Producto." ',' ".$ID_Categoria." ',' ".$Stok_Producto." ');";
- $guardando_productos=mysql_query($productos) or die ('La consulta falló: ' . mysql_error());
- echo "Producto Ingresado con Extito";
- }
- else
- {
- echo "Ingrese el nombre del producto!";
- }
- ?>
- <form name="categoria" method="post" action="insertarproducto.php">
- <p><b>Ingrese un Producto</b></p>
- <table width="48%" border="0" align="center">
- <tr>
- <td width="22%"> Nombre del Producto <label></label> </td>
- <td width="23%"><input type="text" name="Nombre_Producto" id="Nombre_Producto" /></td>
- </tr>
- <tr>
- <td width="22%"> Imagen Producto (URL) <label></label> </td>
- <td width="23%"><input type="text" name="Imagen_Producto" id="Imagen_Producto" /></td>
- </tr>
- <tr>
- <td width="22%"> Descripcion del proudcto <label></label> </td>
- <td width="23%"><input type="text" name="Descripcion_Producto" id="Descripcion_Producto" /></td>
- </tr>
- <tr>
- <td width="22%"> Precio del Producto <label></label> </td>
- <td width="23%"><input type="int" name="Precio_Producto" id="Precio_Producto" /></td>
- </tr>
- <tr>
- <td width="22%"> Categoria del Producto </td>
- <td width="23%">
- <?php
- include ("conexion.php");
- // Realizar una consulta SQL
- $buscarcategoria = "SELECT Nombre_Categoria FROM categoria";
- $resultadocat = mysql_query($buscarcategoria) or die('La consulta falló: ' . mysql_error());
- // Impresion de resultados en HTML
- echo "<select name=\"ID_Categoria\">\n";
- while ($linea = mysql_fetch_array($resultadocat, MYSQL_ASSOC))
- {
- foreach ($linea as $valor_col)
- {
- echo " <option value=\"$valor_col\"> $valor_col </option>\n";
- }
- }
- $res=$row["ID_Categoria"];
- echo "</select>\n";
- // Liberar conjunto de resultados
- mysql_free_result($resultadocat);
- ?></td>
- </tr>
- <tr>
- <td width="22%"> Unidades en Stok <label></label> </td>
- <td width="23%"><input type="text" name="Stok_Producto" id="Stok_Producto" /></td>
- </tr>
- <tr>
- <td colspan="3"> <label>
- <div align="center">
- <input type="submit" name="registrar" id="registrar" value="Registrar">
- <input type="reset" name="registrar2" id="registrar2" value="Limpiar" />
- </div>
- </label> </td>
- </tr>
- </table>
- <p><br>
- </p>
- </form>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement