guarda 2 veces en la base de datos
Publicado por Cristian (2 intervenciones) el 07/01/2008 02:45:16
Bueno tengo el siguiente problema, al llenar el formulario y enviarlo lo guarda 2 veces en la base de datos aca les dejo el codigo si me pueden ayudar, gracias.
el archivo html con el formulario:
<FORM ACTION="guardar.php">
<div class="style1">
<TABLE align="center">
<TR>
<TD><strong>Codigo :</strong></TD>
<TD>
<INPUT TYPE="text" NAME="codigo" SIZE="20" MAXLENGTH="30" style="width: 80px"></TD>
</TR>
<tr>
<TD><strong>Producto :</strong></TD>
<TD>
<INPUT TYPE="text" NAME="producto" SIZE="20" MAXLENGTH="30" style="width: 200px"></TD>
</tr>
<tr>
<TD><strong>Cantidad :</strong></TD>
<TD>
<INPUT TYPE="text" NAME="cantidad" SIZE="20" MAXLENGTH="30" style="width: 60px"></TD>
</tr>
<tr>
<TD><strong>Fecha de Ingreso :</strong></TD>
<TD>
<INPUT TYPE="text" NAME="feching" SIZE="20" MAXLENGTH="30" style="width: 97px"> (aaaa-mm-dd)</TD>
</tr>
<tr>
<TD><strong>Fecha de Salida :</strong></TD>
<TD>
<INPUT TYPE="text" NAME="fechsal" SIZE="20" MAXLENGTH="30" style="width: 97px">
(aaaa-mm-dd)</TD>
</tr>
<tr>
<TD><strong>Factura :</strong></TD>
<TD><INPUT TYPE="text" NAME="factura" SIZE="20" MAXLENGTH="80"></TD>
</tr>
<TR>
<TD><strong>Letra :</strong></TD>
<TD><INPUT TYPE="text" NAME="letra" SIZE="20" MAXLENGTH="80"></TD>
</TR>
</TABLE>
<INPUT TYPE="submit" NAME="accion" VALUE="Guardar">
<INPUT TYPE="reset" NAME="accion0" VALUE="Limpiar"></div>
</FORM>
Archivo guardar.php
<?php
include("conexion.php");
$db=conectar();
$codigo=$_GET['codigo'];
$producto=$_GET['producto'];
$cantidad=$_GET['cantidad'];
$feching=$_GET['feching'];
$fechsal=$_GET['fechsal'];
$factura=$_GET['factura'];
$letra=$_GET['letra'];
mysql_query("insert into agro (codigo,producto,cantidad,feching,fechsal,factura,letra)
values ('$codigo','$producto','$cantidad','$feching','$fechsal','$factura','$letra')",$db);
?>
ayuda porfa :)
el archivo html con el formulario:
<FORM ACTION="guardar.php">
<div class="style1">
<TABLE align="center">
<TR>
<TD><strong>Codigo :</strong></TD>
<TD>
<INPUT TYPE="text" NAME="codigo" SIZE="20" MAXLENGTH="30" style="width: 80px"></TD>
</TR>
<tr>
<TD><strong>Producto :</strong></TD>
<TD>
<INPUT TYPE="text" NAME="producto" SIZE="20" MAXLENGTH="30" style="width: 200px"></TD>
</tr>
<tr>
<TD><strong>Cantidad :</strong></TD>
<TD>
<INPUT TYPE="text" NAME="cantidad" SIZE="20" MAXLENGTH="30" style="width: 60px"></TD>
</tr>
<tr>
<TD><strong>Fecha de Ingreso :</strong></TD>
<TD>
<INPUT TYPE="text" NAME="feching" SIZE="20" MAXLENGTH="30" style="width: 97px"> (aaaa-mm-dd)</TD>
</tr>
<tr>
<TD><strong>Fecha de Salida :</strong></TD>
<TD>
<INPUT TYPE="text" NAME="fechsal" SIZE="20" MAXLENGTH="30" style="width: 97px">
(aaaa-mm-dd)</TD>
</tr>
<tr>
<TD><strong>Factura :</strong></TD>
<TD><INPUT TYPE="text" NAME="factura" SIZE="20" MAXLENGTH="80"></TD>
</tr>
<TR>
<TD><strong>Letra :</strong></TD>
<TD><INPUT TYPE="text" NAME="letra" SIZE="20" MAXLENGTH="80"></TD>
</TR>
</TABLE>
<INPUT TYPE="submit" NAME="accion" VALUE="Guardar">
<INPUT TYPE="reset" NAME="accion0" VALUE="Limpiar"></div>
</FORM>
Archivo guardar.php
<?php
include("conexion.php");
$db=conectar();
$codigo=$_GET['codigo'];
$producto=$_GET['producto'];
$cantidad=$_GET['cantidad'];
$feching=$_GET['feching'];
$fechsal=$_GET['fechsal'];
$factura=$_GET['factura'];
$letra=$_GET['letra'];
mysql_query("insert into agro (codigo,producto,cantidad,feching,fechsal,factura,letra)
values ('$codigo','$producto','$cantidad','$feching','$fechsal','$factura','$letra')",$db);
?>
ayuda porfa :)
Valora esta pregunta


0