Ver Mensaje Individual
  #3 (permalink)  
Antiguo 12/09/2011, 11:07
l222p
 
Fecha de Ingreso: julio-2010
Mensajes: 191
Antigüedad: 13 años, 10 meses
Puntos: 2
Respuesta: problema al guardar datos en mySQL

Les mostrare todo el codigo, que viene en 3 archivos

index.php
Código PHP:
Ver original
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
  2. <html>
  3.     <head>
  4.         <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  5.         <title></title>
  6.     </head>
  7.     <body>
  8.         <?php
  9.         $conexion=mysql_connect("localhost","l222p","l222p");
  10.         mysql_select_db("ejemplo",$conexion)or die ("No se puede conectar");
  11.         ?>
  12.     </body>
  13. </html>

ingresar.php

Código PHP:
Ver original
  1. <!--
  2. To change this template, choose Tools | Templates
  3. and open the template in the editor.
  4. -->
  5. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
  6. <html>
  7.     <head>
  8.         <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  9.         <title>Ingresar Datos</title>
  10.     </head>
  11.    
  12.     <body>
  13.           <font face="Tw Cen MT" size="6">
  14.              
  15.         <body style="background-attachment: fixed; background-repeat: no-repeat;"
  16. background="background.jpg">
  17.  
  18.     <center>    
  19. <img src="ingresar datos.png"><br><br><br>
  20.         <form action="ingresar.php">
  21.             Descripción: <input type="text" name="descripcion" size="10"><br>
  22.             Precio al Costo: <input name="preciocosto" type="text" size="10"><br>
  23.             Precio a la Venta: <input name="precioventa" type="text" size="10"><br>
  24.             Stock Anual: <input name="stockanual" type="text" size="10"><br>
  25.             Stock Minimo: <input name="stockminimo" type="text" size="10"><br><br>
  26.             <input type="submit" value="Guardar" name="action" style="width:90px; height:30px; color:#ffffff; background-image: url(boton.png); font-size: 20px; font-family: Tw Cen MT">
  27.         </form>
  28.         <?php
  29.         error_reporting(0);
  30.         include("index.php");
  31.         $descripcion=$_GET{'descripcion'};
  32.         $preciocosto=$_GET{'preciocosto'};
  33.         $precioventa=$_GET{'precioventa'};
  34.         $stockanual=$_GET{'stockanual'};
  35.         $stockminimo=$_GET{'stockminimo'};
  36.  
  37.         mysql_query("INSERT INTO articulos (descripcion,preciocosto,precioventa,stockanual,stockminimo) VALUES('$descripcion','$preciocosto','$precioventa','$stockanual','$stockminimo')");
  38.  
  39.         ?>
  40. <a href="mostrar.php"><img src="mostrar datos.png" width="150" height="55" align="right"></a>
  41.     </center>
  42.             </font>
  43.     </body>
  44. </html>


mostrar.php

Código PHP:
Ver original
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
  2. <html>
  3.     <head>
  4.         <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  5.         <title></title>
  6.     </head>
  7.     <body>
  8.         <font face="Tw Cen MT" size="6">
  9.  
  10.         <body style="background-attachment: fixed; background-repeat: no-repeat;"
  11. background="background.jpg">
  12.  
  13.     <center>
  14. <img src="mostrar datos.png"><br>
  15.  
  16. <br><br>
  17.         <?php
  18.         error_reporting(0);
  19.         include("index.php");
  20.         $resultado=mysql_query("SELECT * FROM articulos");
  21.         echo "<TABLE BORDER='1'>";
  22.         echo "<tr>";
  23.         echo "<th>Código</th><th>Descripción</th><th>Precio al Costo</th><th>Precio a la Venta</th><th>Stock Anual</th><th>Stock Mínimo</th>";
  24.         echo "</tr>";
  25.  
  26.         while($r=  mysql_fetch_array($resultado)){
  27.             echo "<tr>";
  28.             echo "<td>",$r{'codigo'},"</td><td>",$r{'descripcion'},"</td><td>",$r{'preciocosto'},"</td><td>",$r{'precioventa'},"</td><td>",$r{'stockanual'},"</td><td>",$r{'stockminimo'},"</td>";
  29.             echo "</tr>";
  30.            
  31.         }
  32. echo"</TABLE>";
  33.             mysql_close($conexion);
  34.         ?>
  35. <br><br><br><br><br>
  36. <a href="ingresar.php"><img src="ingresar datos.png" width="150" height="55" align="right"></a>
  37.     </center>
  38.     </body>
  39.     </font>
  40. </html>