Advertisement
Guest User

Untitled

a guest
Aug 18th, 2017
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.90 KB | None | 0 0
  1. <head>
  2.  
  3.     <title>Insertar producto</title>
  4.  
  5.     <link rel="stylesheet" type="text/css" href="estilo.css" />
  6.  
  7.   </head>
  8.  
  9.  
  10.  
  11. <?php
  12.  
  13.     include ("conexion.php");
  14.  
  15.     $Nombre_Producto=$_POST['Nombre_Producto'];
  16.  
  17.     $Imagen_Producto=$_POST['Imagen_Producto'];
  18.  
  19.     $Descripcion_Producto=$_POST['Descripcion_Producto'];
  20.  
  21.     $Precio_Producto=$_POST['Precio_Producto'];
  22.  
  23.     $ID_Categoria=$_POST['ID_Categoria'];
  24.  
  25.     $Stok_Producto=$_POST['Stok_Producto'];
  26.  
  27.  
  28.  
  29.     if ($Nombre_Producto != NULL/* && $Descripcion_Producto != NULL && $Precio_Producto != NULL && $Categoria_Producto != NULL && $Stok_Producto != NULL*/)
  30.  
  31.     {
  32.  
  33.         $productos = "INSERT INTO productos VALUES ('$ID_Producto',' ".$Nombre_Producto." ',' ".$Imagen_Producto." ',' ".$Descripcion_Producto." ',' ".$Precio_Producto." ',' ".$ID_Categoria." ',' ".$Stok_Producto." ');";
  34.  
  35.         $guardando_productos=mysql_query($productos) or die ('La consulta falló: ' . mysql_error());
  36.  
  37.         echo "Producto Ingresado con Extito";
  38.  
  39.     }
  40.  
  41.     else
  42.  
  43.     {
  44.  
  45.         echo "Ingrese el nombre del producto!";
  46.  
  47.     }
  48.  
  49. ?>
  50.  
  51.  
  52.  
  53.                     <form name="categoria" method="post" action="insertarproducto.php">
  54.  
  55.                      <p><b>Ingrese un Producto</b></p>
  56.  
  57.  
  58.  
  59.                      <table width="48%" border="0" align="center">
  60.  
  61.                      <tr>
  62.  
  63.                      <td width="22%">   Nombre del Producto  <label></label>     </td>
  64.  
  65.                      <td width="23%"><input type="text" name="Nombre_Producto" id="Nombre_Producto" /></td>
  66.  
  67.                      </tr>
  68.  
  69.                      <tr>
  70.  
  71.                      <td width="22%">  Imagen Producto  (URL) <label></label>     </td>
  72.  
  73.                      <td width="23%"><input type="text" name="Imagen_Producto" id="Imagen_Producto" /></td>
  74.  
  75.                      </tr>
  76.  
  77.                      <tr>
  78.  
  79.                      <td width="22%">  Descripcion del proudcto   <label></label>     </td>
  80.  
  81.                      <td width="23%"><input type="text" name="Descripcion_Producto" id="Descripcion_Producto" /></td>
  82.  
  83.                      </tr>
  84.  
  85.                      <tr>
  86.  
  87.                      <td width="22%">  Precio del Producto   <label></label>     </td>
  88.  
  89.                      <td width="23%"><input type="int" name="Precio_Producto" id="Precio_Producto" /></td>
  90.  
  91.                      </tr>
  92.  
  93.                      <tr>
  94.  
  95.                      <td width="22%">  Categoria del Producto                      </td>
  96.  
  97.                      <td width="23%">
  98.  
  99.             <?php
  100.  
  101.                 include ("conexion.php");
  102.  
  103.                 // Realizar una consulta SQL
  104.  
  105.                 $buscarcategoria = "SELECT Nombre_Categoria FROM categoria";
  106.  
  107.                 $resultadocat = mysql_query($buscarcategoria) or die('La consulta falló: ' . mysql_error());
  108.  
  109.  
  110.  
  111.             // Impresion de resultados en HTML
  112.  
  113.             echo "<select name=\"ID_Categoria\">\n";
  114.  
  115.             while ($linea = mysql_fetch_array($resultadocat, MYSQL_ASSOC))
  116.  
  117.             {
  118.  
  119.                 foreach ($linea as $valor_col)
  120.  
  121.                 {
  122.  
  123.                                         echo " <option value=\"$valor_col\"> $valor_col </option>\n";
  124.  
  125.                 }
  126.  
  127.             }
  128.  
  129.             $res=$row["ID_Categoria"];
  130.  
  131.             echo "</select>\n";
  132.  
  133.             // Liberar conjunto de resultados
  134.  
  135.             mysql_free_result($resultadocat);
  136.  
  137.  
  138.  
  139.             ?></td>
  140.  
  141.                      </tr>
  142.  
  143.                      <tr>
  144.  
  145.                      <td width="22%">  Unidades en Stok   <label></label>     </td>
  146.  
  147.                      <td width="23%"><input type="text" name="Stok_Producto" id="Stok_Producto" /></td>
  148.  
  149.                      </tr>
  150.  
  151.  
  152.  
  153.                 <tr>
  154.  
  155.                 <td colspan="3"> <label>
  156.  
  157.                   <div align="center">
  158.  
  159.                     <input type="submit" name="registrar" id="registrar" value="Registrar">
  160.  
  161.                     <input type="reset" name="registrar2" id="registrar2" value="Limpiar" />
  162.  
  163.                   </div>
  164.  
  165.                 </label>  </td>
  166.  
  167.                 </tr>
  168.  
  169.             </table>
  170.  
  171.           <p><br>
  172.  
  173.         </p>
  174.  
  175.       </form>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement