Club Delphi  
    FTP   CCD     Buscar   Trucos   Trabajo   Foros

Retroceder   Foros Club Delphi > Otros entornos y lenguajes > PHP
Registrarse FAQ Miembros Calendario Guía de estilo Temas de Hoy

Respuesta
 
Herramientas Buscar en Tema Desplegado
  #1  
Antiguo 28-01-2005
elizabethdesa elizabethdesa is offline
Registrado
 
Registrado: ene 2005
Posts: 2
Poder: 0
elizabethdesa Va por buen camino
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 ?>&nbsp;<?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)">&nbsp;</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 ?>&nbsp;<?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
Responder Con Cita
  #2  
Antiguo 31-01-2005
damian damian is offline
Registrado
 
Registrado: ene 2005
Ubicación: Holguín - Cuba
Posts: 2
Poder: 0
damian Va por buen camino
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
Responder Con Cita
  #3  
Antiguo 02-02-2005
elizabethdesa elizabethdesa is offline
Registrado
 
Registrado: ene 2005
Posts: 2
Poder: 0
elizabethdesa Va por buen camino
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
Responder Con Cita
Respuesta



Normas de Publicación
no Puedes crear nuevos temas
no Puedes responder a temas
no Puedes adjuntar archivos
no Puedes editar tus mensajes

El código vB está habilitado
Las caritas están habilitado
Código [IMG] está habilitado
Código HTML está deshabilitado
Saltar a Foro


La franja horaria es GMT +2. Ahora son las 21:56:12.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi
Copyright 1996-2007 Club Delphi