Вы находитесь на странице: 1из 15

INDEX.

PHP

<?php require_once('Connections/Carrito.php'); ?> <?php if (!function_exists("GetSQLValueString")) { function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { if (PHP_VERSION < 6) { $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue; }

$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue); switch ($theType) { case "text": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "long": case "int": $theValue = ($theValue != "") ? intval($theValue) : "NULL"; break; case "double": $theValue = ($theValue != "") ? doubleval($theValue) : "NULL"; break; case "date": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue; } } mysql_select_db($database_Carrito, $Carrito); $query_listado = "SELECT * FROM fotos_mias"; $listado = mysql_query($query_listado, $Carrito) or die(mysql_error()); $row_listado = mysql_fetch_assoc($listado); $totalRows_listado = mysql_num_rows($listado); ?> <!-- InstanceBegin template="/Templates/carrito.dwt.php" codeOutsideHTMLIsLocked="false" -><!-- InstanceBeginEditable name="head" --> <!-- InstanceEndEditable --> <style type="text/css"> body { margin-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; } </style>

<table width="100%" border="0"> <tr> <td><img src="imagenes/logo.jpg" width="624" height="53"></td> </tr> <tr> <td><table width="100%" border="0"> <tr align="center"> <td bgcolor="#799096"><a href="index.php">Inicio</a></td> <td bgcolor="#799096"><a href="carrito_compra.php">Carrito de compra</a></td> <td bgcolor="#799096">Upload</td> <td bgcolor="#799096">Contacto</td> </tr> </table></td> </tr> <tr> <td><!-- InstanceBeginEditable name="edicion" --> <table width="100%" border="0"> <tr> <td height="71" align="center"><h1>Listado de Fotos</h1></td> </tr> </table> <table width="100%" border="0" cellpadding="0" cellspacing="0"> <?php $cuantos=0; do { if($cuantos==0){ ?> <tr> <?php }$cuantos++;?> <td height="206" align="center"><p><a href="detalle.php?foto_id=<?php echo $row_listado['foto_id']; ?>"><img src="fotos/peques/<?php echo $row_listado['nombre']; ?>" width="120" height="72"></a></p> <p><strong><?php echo $row_listado['lugar']; ?></strong><br /> <?php echo $row_listado['precio']; ?>Soles<br /> </p> <form id="form1" name="form1" method="post" action="carrito_compra.php"> <input name="cantidad" type="hidden" id="cantidad" value="1" /> <input name="precio" type="hidden" id="precio" value="<?php echo $row_listado['precio']; ?>" /> <input name="lugar" type="hidden" id="lugar" value="<?php echo $row_listado['lugar']; ?>" />

<input type="image" name="imageField" id="imageField" src="imagenes/carrito.gif" /> </form> <p><br /> <br /> <br /> </p></td> <?php if($cuantos==3){ $cuantos=0; ?> </tr> <?php } ?> <?php } while ($row_listado = mysql_fetch_assoc($listado)); ?> </table> <table border="0"> <tr> <td><?php if ($pageNum_listado > 0) { // Show if not first page ?> <a href="<?php printf("%s?pageNum_listado=%d%s", $currentPage, 0, $queryString_listado); ?>">Primero</a> <?php } // Show if not first page ?></td> <td><?php if ($pageNum_listado > 0) { // Show if not first page ?> <a href="<?php printf("%s?pageNum_listado=%d%s", $currentPage, max(0, $pageNum_listado - 1), $queryString_listado); ?>">Anterior</a> <?php } // Show if not first page ?></td> <td><?php if ($pageNum_listado < $totalPages_listado) { // Show if not last page ?> <a href="<?php printf("%s?pageNum_listado=%d%s", $currentPage, min($totalPages_listado, $pageNum_listado + 1), $queryString_listado); ?>">Siguiente</a> <?php } // Show if not last page ?></td> <td><?php if ($pageNum_listado < $totalPages_listado) { // Show if not last page ?> <a href="<?php printf("%s?pageNum_listado=%d%s", $currentPage, $totalPages_listado, $queryString_listado); ?>">&Uacute;ltimo</a> <?php } // Show if not last page ?></td> </tr> </table> </p> <p>&nbsp;</p> <!-- InstanceEndEditable --></td> </tr> </table> <!-- InstanceEnd --> <?php mysql_free_result($listado); ?>

DETALLE.PHP

<?php require_once('Connections/Carrito.php'); ?> <?php if (!function_exists("GetSQLValueString")) { function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { if (PHP_VERSION < 6) { $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue; } $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue); switch ($theType) { case "text": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "long": case "int": $theValue = ($theValue != "") ? intval($theValue) : "NULL"; break; case "double": $theValue = ($theValue != "") ? doubleval($theValue) : "NULL"; break; case "date": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue; } } $colname_detalle = "-1"; if (isset($_GET['foto_id'])) { $colname_detalle = $_GET['foto_id'];

} mysql_select_db($database_Carrito, $Carrito); $query_detalle = sprintf("SELECT * FROM fotos_mias WHERE foto_id = %s", GetSQLValueString($colname_detalle, "int")); $detalle = mysql_query($query_detalle, $Carrito) or die(mysql_error()); $row_detalle = mysql_fetch_assoc($detalle); $totalRows_detalle = mysql_num_rows($detalle); ?> <!-- InstanceBegin template="/Templates/carrito.dwt.php" codeOutsideHTMLIsLocked="false" -><!-- InstanceBeginEditable name="head" --> <!-- InstanceEndEditable --> <style type="text/css"> body { margin-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; } </style> <table width="100%" border="0"> <tr> <td><img src="imagenes/logo.jpg" width="624" height="53"></td> </tr> <tr> <td><table width="100%" border="0"> <tr align="center"> <td bgcolor="#799096"><a href="index.php">Inicio</a></td> <td bgcolor="#799096"><a href="carrito_compra.php">Carrito de compra</a></td> <td bgcolor="#799096">Upload</td> <td bgcolor="#799096">Contacto</td> </tr> </table></td> </tr> <tr> <td><!-- InstanceBeginEditable name="edicion" --> <table width="100%" border="0"> <tr> <td align="center"><form id="form1" name="form1" method="post" action="carrito_compra.php"> <input name="cantidad" type="hidden" id="cantidad" value="1" />

<input name="precio" type="hidden" id="precio" value="<?php echo $row_detalle['precio']; ?>" /> <input name="lugar" type="hidden" id="lugar" value="<?php echo $row_detalle['lugar']; ?>" /> <input type="image" name="imageField" id="imageField" src="imagenes/carrito.gif" /> </form></td> </tr> <tr> <td align="center"><h2><?php echo $row_detalle['lugar']; ?></h2></td> </tr> <tr> <td align="center"><?php echo $row_detalle['descripcion']; ?></td> </tr> <tr> <td align="center"><img src="fotos/grandes/<?php echo $row_detalle['nombre']; ?>" width="698" height="420"></td> </tr> </table> <!-- InstanceEndEditable --></td> </tr> </table> <!-- InstanceEnd --> <?php mysql_free_result($detalle); ?>

CARRITO_COMPRA.PHP

<?php session_start(); if(isset($_SESSION['carrito']) || isset($_POST['lugar'])){ if(isset($_SESSION['carrito'])){ $carrito_mio=$_SESSION['carrito']; if(isset($_POST['lugar'])){ $lugar=$_POST['lugar']; $precio=$_POST['precio']; $cantidad=$_POST['cantidad']; $donde=-1; for($i=0;$i<=count($carrito_mio)-1;$i++){

if($lugar==$carrito_mio[$i]['lugar']){ $donde=$i;} } if($donde !=-1){ $cuanto=$carrito_mio[$donde]['cantidad']+$cantidad; $carrito_mio[$donde]=array("lugar"=>$lugar,"precio"=>$precio,"cantidad"=>$cuanto); }else{ $carrito_mio[]=array("lugar"=>$lugar,"precio"=>$precio,"cantidad"=>$cantidad);} } }else{ $lugar=$_POST['lugar']; $precio=$_POST['precio']; $cantidad=$_POST['cantidad']; $carrito_mio[]=array("lugar"=>$lugar,"precio"=>$precio,"cantidad"=>$cantidad ); } if(isset($_POST['cantidad2'])){ $id=$_POST['id']; $cuantos=$_POST['cantidad2']; if($cuantos<1){ $carrito_mio[$id]=NULL; }else{ $carrito_mio[$id]['cantidad']=$cuantos; } } if(isset($_POST['id2'])){ $id=$_POST['id2']; $carrito_mio[$id]=NULL; } $_SESSION['carrito']=$carrito_mio; } /*if(isset($_POST['lugar'])){ $lugar=$_POST['lugar']; $precio=$_POST['precio']; $cantidad=$_POST['cantidad']; }*/ ?> <!-- InstanceBeginEditable name="head" -->

<!-- InstanceEndEditable --> <style type="text/css"> body { margin-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; } </style> <table width="100%" border="0"> <tr> <td><img src="imagenes/logo.jpg" width="624" height="53"></td> </tr> <tr> <td><table width="100%" border="0"> <tr align="center"> <td bgcolor="#799096"><a href="index.php">Inicio</a></td> <td bgcolor="#799096"><a href="carrito_compra.php">Carrito de compra</a></td> <td bgcolor="#799096">Upload</td> <td bgcolor="#799096">Contacto</td> </tr> </table></td> </tr> <tr> <td><!-- InstanceBeginEditable name="edicion" --> <p><a href="javascript:history.back(1)">Volver atras</a></p> <h2 align="center">Carrito Compra </h2> <table width="89%" border="0" cellspacing="0"> <tr bgcolor="#698287"> <td width="53%"><strong>Nombre</strong></td> <td width="12%" align="right"><strong>Precio</strong></td> <td width="12%" align="right"><strong>Cantidad</strong></td> <td width="16%" align="center"><strong>Total</strong></td> <td width="7%" align="right">&nbsp;</td> </tr> <?php if(isset($_SESSION['carrito'])){

$total=0; for($i=0;$i<=count($carrito_mio)-1;$i++){ if($carrito_mio[$i] !=NULL) { ?> <tr> <td bgcolor="#B7C6CB"><?php print $carrito_mio[$i]['lugar'] /*print $lugar*/ ?></td> <td align="right" bgcolor="#B7C6CB"><?php print $carrito_mio[$i]['precio'] /*print $precio*/ ?></td> <td align="center" bgcolor="#B7C6CB"> <form name="form1" method="post" action=""> <input name="id" type="hidden" id="id" value="<?php print $i;?>"> <input name="cantidad2" type="text" id="cantidad2" value="<?php print $carrito_mio[$i]['cantidad'] ?>" size="2"> <input type="image" name="imageField" id="imageField" src="imagenes/actualizar.gif"> </form></td> <td align="right" bgcolor="#B7C6CB"><?php print $carrito_mio[$i]['precio']*$carrito_mio[$i]['cantidad'] ?></td> <td align="right" bgcolor="#B7C6CB"><form name="form2" method="post" action=""> <input name="id2" type="hidden" id="id2" value="<?php print $i;?>"> <input type="image" name="imageField2" id="imageField2" src="imagenes/papelera.gif"> </form></td> </tr> <?php $total=$total+( $carrito_mio[$i]['precio']*$carrito_mio[$i]['cantidad']); } } }?> <tr> <td>&nbsp;</td> <td>&nbsp;</td> <td><strong>Total:</strong></td> <td align="right"><?php if(isset($_SESSION['carrito'])){ print $total; }?> Soles</td> <td>&nbsp;</td> </tr> <tr> <td>&nbsp;</td>

<td colspan="3" align="center"><form name="form3" method="post" action="resumen.php"> <input type="submit" name="button" id="button" value="Enviar Pedido"> </form></td> <td>&nbsp;</td> </tr> </table> <p>&nbsp;</p> <!-- InstanceEndEditable --></td> </tr> </table> <!-- InstanceEnd -->

RESUMEN.PHP

<?php session_start(); if(isset($_SESSION['carrito'])){ $carrito_mio=$_SESSION['carrito']; } ?> <!-- InstanceBegin template="/Templates/carrito.dwt.php" codeOutsideHTMLIsLocked="false" -><!-- InstanceBeginEditable name="head" --> <!-- InstanceEndEditable --> <style type="text/css"> body { margin-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; } </style> <table width="100%" border="0"> <tr> <td><img src="imagenes/logo.jpg" width="624" height="53"></td> </tr>

<tr> <td><table width="100%" border="0"> <tr align="center"> <td bgcolor="#799096"><a href="index.php">Inicio</a></td> <td bgcolor="#799096"><a href="carrito_compra.php">Carrito de compra</a></td> <td bgcolor="#799096">Upload</td> <td bgcolor="#799096">Contacto</td> </tr> </table></td> </tr> <tr> <td><!-- InstanceBeginEditable name="edicion" --> <form action="final.php" method="post"> <p align="center">Resumen del carrito de compra</p><table width="78%" border="0" cellspacing="0"> <tr bgcolor="#698287"> <td align="right" bgcolor="#FFFFFF">Nombre</td> <td colspan="3" align="left" bgcolor="#FFFFFF"><label for="nombre"></label> <input type="text" name="nombre" id="nombre"></td> </tr> <tr bgcolor="#698287"> <td align="right" bgcolor="#FFFFFF">E-Mail</td> <td colspan="3" align="left" bgcolor="#FFFFFF"><label for="correo"></label> <input name="correo" type="text" id="correo" size="40"></td> </tr> <tr bgcolor="#698287"> <td width="53%"><strong>Nombre</strong></td> <td width="12%" align="right"><strong>Precio</strong></td> <td width="12%" align="right"><strong>Cantidad</strong></td> <td width="16%" align="center"><strong>Total</strong></td> </tr> <?php if(isset($_SESSION['carrito'])){ $total=0; for($i=0;$i<=count($carrito_mio)-1;$i++){ if($carrito_mio[$i] !=NULL) { ?> <tr> <td bgcolor="#B7C6CB"><?php print $carrito_mio[$i]['lugar'] /*print $lugar*/ ?></td>

<td align="right" bgcolor="#B7C6CB"><?php print $carrito_mio[$i]['precio'] /*print $precio*/ ?></td> <td align="center" bgcolor="#B7C6CB"><?php print $carrito_mio[$i]['cantidad'] ?></td> <td align="right" bgcolor="#B7C6CB"><?php print $carrito_mio[$i]['precio']*$carrito_mio[$i]['cantidad'] ?></td> </tr> <?php $total=$total+( $carrito_mio[$i]['precio']*$carrito_mio[$i]['cantidad']); } } }?> <tr> <td>&nbsp;</td> <td>&nbsp;</td> <td><strong>Total:</strong></td> <td align="right"><?php if(isset($_SESSION['carrito'])){ print $total; }?> Soles</td> </tr> <tr> <td>&nbsp;</td> <td>&nbsp;</td> <td>&nbsp;</td> <td align="right"><input type="submit" name="button" id="button" value="Enviar pedido a Paypal"></td> </tr> </table> </p> </form> <!-- InstanceEndEditable --></td> </tr> </table> <!-- InstanceEnd -->

FINAL.PHP

<?php session_start();

if(isset($_SESSION['carrito'])){ $carrito_mio=$_SESSION['carrito']; $pedido="Pedido de libros de Asociacin Editorial Bruo. <br><br>"; $total=0; for($i=0;$i<=count($carrito_mio)-1;$i++) { if($carrito_mio[$i]!=NULL){ $pedido .= $carrito_mio[$i]['lugar']."********" . $carrito_mio[$i]['precio']." X ".$carrito_mio[$i]['cantidad']." Total : ".$carrito_mio[$i]['precio']*$carrito_mio[$i]['cantidad'] . "Euros"; $total=$total+ $carrito_mio[$i]['precio']*$carrito_mio[$i]['cantidad']; } } $pedido.="<br><br> Total: ".$total; $nombre=$_POST['nombre']; $email=$_POST['correo']; $pedido.="<br><br>De: ". $nombre; $asunto="Asociacin Editorial Bru"; $empresa="Asociacin Editorial Bruo - Lima"; $correo_empresa="raisnaider@hotmail.com"; mail($email,$asunto,$pedido,"MIME-Version:1.0\nContent-type:text/html;charset=UTF8\nFrom:$empresa<$correo_empresa>"); $asunto.=" Copia "; mail($correo_empresa,$asunto,$pedido,"MIME-Version:1.0\nContenttype:text/html;charset=UTF-8\nFrom:$empresa<$correo_empresa>"); } ?>

<!-- InstanceBegin template="/Templates/carrito.dwt.php" codeOutsideHTMLIsLocked="false" -><!-- InstanceBeginEditable name="head" --> <!-- InstanceEndEditable --> <style type="text/css"> body { margin-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; } </style>

<table width="100%" border="0"> <tr> <td><img src="imagenes/logo.jpg" width="624" height="53"></td> </tr> <tr> <td><table width="100%" border="0"> <tr align="center"> <td bgcolor="#799096"><a href="index.php">Inicio</a></td> <td bgcolor="#799096"><a href="carrito_compra.php">Carrito de compra</a></td> <td bgcolor="#799096">Upload</td> <td bgcolor="#799096">Contacto</td> </tr> </table></td> </tr> <tr> <td><!-- InstanceBeginEditable name="edicion" --> <h2 align="center">Accediendo a Paypal...<br> Espere unos instantes... </h2> <!-- InstanceEndEditable --></td> </tr> </table> <!-- InstanceEnd -->

Вам также может понравиться