![]() |
![]() |
![]() |
![]() |
![]() |
FTP | ![]() |
![]() |
CCD | ![]() |
![]() |
Buscar | ![]() |
![]() |
Trucos | ![]() |
![]() |
Trabajo | ![]() |
![]() |
Foros | ![]() |
|
Registrarse | FAQ | Miembros | Calendario | Guía de estilo | Temas de Hoy |
![]() |
|
Herramientas | Buscar en Tema | Desplegado |
#1
|
|||
|
|||
insertar datos (ayuda urgente)
holas tengo un grave problema
resulta que estoy haciendo un sistema para gestionar las ventas una forma parecido a un carrito de compra y tengo un problema el pedido que hace el cliente funciona perfecto, pero cuando este le da aceptar para insertar su orden en la base de dato, el mismo inserta puros ceros, en cambio si le doy click al codigo del producto me inserta en la bd el codigo de producto únicamente, no me inserta ni el nombre, precio, total,. Ahora bien si le doy click al nombre del producto éste me sigue insertando en la bd el cod del producto y no me inserta los demás campos. Aqui les muestro el codigo la paag. pedido.php llama a insertar.php pedido.php <?php require("config.php"); ?> <html> <head> <link rel="stylesheet" HREF="master_style.css"> </head> <script LANGUAGE="JavaScript"> function showBasket() { index = document.cookie.indexOf("ShoppingBasket"); countbegin = (document.cookie.indexOf("=", index) + 1); countend = document.cookie.indexOf(";", index); if (countend == -1) { countend = document.cookie.length; } fulllist = document.cookie.substring(countbegin, countend); subtotal = 0; document.writeln('<CENTER><FORM NAME="updateform"><font size="5" face="Verdana, Arial, Helvetica, sans-serif"><b><?php echo $txt_cart ?></b></FONT><HR WIDTH=75% size=1 COLOR="#000000">'); document.writeln('<table cellpadding="2" cellspacing="1" border="1">'); document.writeln('<TR><TD BGCOLOR="#FFFFCC"><font size="-2" face="Verdana, Arial, Helvetica, sans-serif"><b><?php echo $txt_cantidad ?></b></FONT></TD><TD BGCOLOR="#FFFFCC"><font size="-2" face="Verdana, Arial, Helvetica, sans-serif"><b><?php echo $txt_cod_producto ?></b></FONT></TD><TD BGCOLOR="#FFFFCC"><font size="-2" face="Verdana, Arial, Helvetica, sans-serif"><b><?php echo $txt_nombre ?></b></FONT></TD><TD BGCOLOR="#FFFFCC"><font size="-2" face="Verdana, Arial, Helvetica, sans-serif"><b><?php echo $txt_precio ?> <?php echo $txt_currency ?></b></FONT></TD><td BGCOLOR="#FFFFCC"><font size="-2" face="Verdana, Arial, Helvetica, sans-serif"><b><?php echo $txt_total ?></b></FONT><TD BGCOLOR="#FFFFCC"><b><FONT COLOR="#FFFFCC">.</FONT></b></TD></TR>'); itemlist = 0; for (var i = 0; i <= fulllist.length; i++) { if (fulllist.substring(i,i+1) == '[') { itemstart = i+1; thisitem = 1; } else if (fulllist.substring(i,i+1) == ']') { itemend = i; thequantity = fulllist.substring(itemstart, itemend); itemtotal = 0; itemtotal = (eval(theprice*thequantity)); temptotal = itemtotal * 100; subtotal = subtotal + itemtotal; itemlist=itemlist+1; document.write('<tr><td align=middle BGCOLOR="#B59F78"><INPUT TYPE=TEXT NAME="quant'+itemlist+'" VALUE="'+thequantity+'" SIZE=3></td><td BGCOLOR="#B59F78"><font size="-2" face="Verdana, Arial, Helvetica, sans-serif"><a href=insertar.php?cod_producto='+thenumber+'>'+thenumber+'</A></FONT></td>'); document.write('<td align=left BGCOLOR="#B59F78"><font size="-2" face="Verdana, Arial, Helvetica, sans-serif"><a href=insertar.php?cod_producto='+thenumber+'>'+theitem+'</A></FONT></td><td align=right BGCOLOR="#B59F78"><font size="-2" face="Verdana, Arial, Helvetica, sans-serif">'+theprice+'</FONT></td><td align=right BGCOLOR="#B59F78"><font size="-2" face="Verdana, Arial, Helvetica, sans-serif">'+top.center.cart.alterError(itemtotal)+'</FONT></td><td WIDTH="38" align=right BGCOLOR="#B59F78"><a href="javascript:updateItem('+itemlist+',document.updateform.quant'+itemlist+'.value)"> </td></tr>'); } else if (fulllist.substring(i,i+1) == '|') { if (thisitem==1) theitem = fulllist.substring(itemstart, i); if (thisitem==2) theprice = fulllist.substring(itemstart, i); if (thisitem==3) thenumber = fulllist.substring(itemstart, i); if (thisitem==4) theweight = fulllist.substring(itemstart, i); thisitem++; itemstart=i+1; } } document.writeln('<tr><td align=right BGCOLOR="#FFFFCC" colspan=4><font size="-2" face="Verdana, Arial, Helvetica, sans-serif"><b><?php echo $txt_product_total ?> <?php echo $txt_currency ?></b></FONT></td><td align=right BGCOLOR="#B59F78"><font size="-2" face="Verdana, Arial, Helvetica, sans-serif">'+top.center.cart.alterError(subtotal)+'</FONT></td><td BGCOLOR="#FFFFCC"><FONT COLOR="#FFFFCC">.</FONT></td></tr>'); document.writeln('</TABLE><CENTER><font size="1" face="Verdana, Arial, Helvetica, sans-serif"></FONT></CENTER>'); document.writeln('</FORM>'); } function updateItem(itemno, newquant) { newItemList = null; itemlist = 0; for (var i = 0; i <= fulllist.length; i++) { if (fulllist.substring(i,i+1) == '[') { thisitem = 1; itemstart = i+1; fullstart = i+1; } else if (fulllist.substring(i,i+1) == ']') { itemend = i; itemlist=itemlist+1; if (itemlist != itemno) { newItemList = newItemList+'['+fulllist.substring(fullstart, itemend)+']'; } else { newItemList = newItemList + '['+theitem+'|'+theprice+'|'+thenumber+'|'+theweight+'|'+newquant+']'; } } else if (fulllist.substring(i,i+1) == '|') { if (thisitem==1) theitem = fulllist.substring(itemstart, i); if (thisitem==2) theprice = fulllist.substring(itemstart, i); if (thisitem==3) thenumber = fulllist.substring(itemstart, i); if (thisitem==4) theweight = fulllist.substring(itemstart, i); thisitem++; itemstart=i+1; } } index = document.cookie.indexOf("ShoppingBasket"); document.cookie="ShoppingBasket="+newItemList; self.location = "basket.php"; top.center.frames[2].location = "middle_right.php"; } function removeItem(itemno) { newItemList = null; itemlist = 0; for (var i = 0; i <= fulllist.length; i++) { if (fulllist.substring(i,i+1) == '[') { itemstart = i+1; } else if (fulllist.substring(i,i+1) == ']') { itemend = i; theitem = fulllist.substring(itemstart, itemend); itemlist=itemlist+1; if (itemlist != itemno) { newItemList = newItemList+'['+fulllist.substring(itemstart, itemend)+']'; } } } index = document.cookie.indexOf("ShoppingBasket"); document.cookie="ShoppingBasket="+newItemList; self.location = "basket.php"; top.center.frames[2].location = "middle_right.php"; } function clearBasket() { if (confirm('<?php echo $txt_clear_shopping_cart ?>?')) { index = document.cookie.indexOf("ShoppingBasket"); document.cookie="ShoppingBasket=."; self.location = "basket_empty.php"; top.center.frames[2].location = "middle_right.php"; } } </script> <BODY TEXT="#000000" BGCOLOR="#B59F78" LINK="#660101" VLINK="#660101" ALINK="#F70404"> <p align="center"> <script LANGUAGE="JavaScript"> showBasket(); </script> </p> <center> <TABLE BORDER=0 CELLSPACING=2 CELLPADDING=3> <TR VALIGN=Top> <TD><FORM METHOD="post" ACTION="insertar.php"><input type="submit" name="aceptar" value="aceptar" class="button"> </FORM></TD> <TD><FORM><INPUT TYPE="BUTTON" NAME="clear" VALUE="<?php echo $txt_clear_cart ?>" class="button" ONCLICK="clearBasket()"></FORM></TD> </TR> </TABLE> </center> </body> </html> ------------------------------------------------------------------------------ insertar.php <?php require("config.php"); $cantidad=$_REQUEST["cantidad"]; $cod_producto=$_REQUEST["cod_producto"]; $nombre=$_REQUEST["nombre"]; $precio=$_REQUEST["precio"]; $txt_currency =$_REQUEST["currency"]; // database connection mysql_connect("$host","$user","$pass"); // database selection mysql_select_db("$database"); mysql_query("insert into factura values('','$cantidad','$cod_producto','$nombre','$precio','$currency')"); header("Location: pedido.php"); ?> les agradezco la yuda porfavor |
#2
|
|||
|
|||
código para insertar en la base de datos.
hola
$query = "INSERT INTO factura (cantidad,cod_producto,nombre,precio,currency) VALUES (''$cantidad'','$cod_producto','$nombre','$precio','$currency')"; Creo que te falta por poner los campos de la base de datos en los que tienes que introducir esos datos. los que están en () prueba a ver si solucionas el problema y escribe damian |
#3
|
|||
|
|||
Gracias, pero ya hice lo que me dijistes y nada sigo en la misma, yo creo que el problema está en pedido.php pero no lo veo, si me puedes ayudar te lo agradecería
|
![]() |
|
|
![]() |
|