Ver Mensaje Individual
  #1 (permalink)  
Antiguo 05/08/2012, 22:33
alely
 
Fecha de Ingreso: agosto-2012
Mensajes: 1
Antigüedad: 11 años, 8 meses
Puntos: 0
carrito y envio de datos

Hola! soy nueva en esto y necesitaria de su ayuda, luego de mucho leer y hacer cambios me decido a escribirles, estoy practicando con un carrito y mi idea es que al terminar de ver la cesta se llene un formulario y se envien los datos del formulario y los datos de la compra por mail, pero solo recibo los datos del comprador porque no se como agregar los otros.Espero puedan ayudarme.Gracias!

Este es el script que ordena la compra y funciona bien

Código PHP:
<? session_start();?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>MI PEDIDO</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" href="http://blogdephp.com/script/php/e-commerce/estilo.css" type="text/css" media="screen">
<style type="text/css">
body {
    background: rgb(102,153,204);
    font: 10pt Verdana, Geneva, Arial, Helvetica, sans-serif;
    background-color: #FF00FF;
    margin-top: 0px;
    background-image: url(images/bkg.jpg);
    }

body,td,th {
    color: #FF00FF;
}
</style>
</head>
<body>
<form action="validarcarrito.php" method="post">

<?
if(isset($_POST['producto'])){ // Para evitar agregar un producto al carrito cuando el usuario sólo presionó el link "Ver cesta"
$_SESSION['productos_ordenados'][]=array(

"producto"=> $_POST['producto'],
"unidades"=> $_POST['unidades'],
"talle"=> $_POST['talle'],
"precio-unitario"=> $_POST['precio-unitario'],
"subtotal"=> $_POST['precio-unitario']*$_POST['unidades']
);
}
?>

<div id="contenedor">
<div id="cabecera">

</div>
<div id="cuerpo">
<div id="principal_carrito">
<ul>
<li>
<ul class="productos_ordenados Negrita">
<li>Producto<div id="navegacion_carrito"><a href="camisas.html"></a> | <a href="ordenar_producto.php"></a> | <a href="javascript:history.back(1)">Volver</a></div></li>
<li>Unidades</li>
<li>Talle</li>
<li>Precio Unitario</li>
<li>Subtotal</li>
</ul>
</li>

<?
if(isset($_SESSION['productos_ordenados'])){
foreach(
$_SESSION['productos_ordenados'] as $producto_ordenado){
$importe_total=$importe_total+$producto_ordenado['subtotal'];
?>

<li>
<ul class="productos_ordenados">
<li>
<?= $producto_ordenado['producto'];?>
</li>
<li>
<?= $producto_ordenado['unidades'];?>
</li>
<li>
<?= $producto_ordenado['talle'];?>
</li>
<li>$
<?= $producto_ordenado['precio-unitario'];?>
</li>
<li>$
<?= $producto_ordenado['subtotal'];?>

</li>
</ul>
</li>

<?
}
?>

<li>
<ul class="productos_ordenados total">
<li><label class="Negrita">Total:</label></li>
<li></li>
<li></li>
<li><label class="Negrita">$
<?= $importe_total;?>
</label></li>
</ul>
</li>

<?
}
else{
?>
<li>Su cesta se encuentra vacía</li>


<?
}
?>
<a href="vaciarcarrito.php"><img src="images/vaciar-carro.png" width="30" height="23"></a>

  <table width: 100%;" border="0" cellpadding="2" cellspacing="2">
    <tbody>
      <tr>
        <td></td>
        <td>Todos los campos son obligatorios:</td>
      </tr>
      <tr>
        <td>Nombre:</td>
        <td><input "hidden"  name="nombre" size="35" maxlength="50" type="text"></td>
      </tr>
      <tr>
        <td>Apellidos:</td>
        <td><input "hidden" name="apellido" size="35" maxlength="50" type="text"></td>
      </tr>
      <tr>
        <td>Telefono:</td>
        <td><input "hidden" name="tel" size="35" maxlength="100" type="text"></td>
      </tr>
      <tr>
        <td>E-mail:</td>
        <td><input "hidden" name="email" size="35" maxlength="100" type="text"></td>
      </tr>
      <tr>
      
      <td>Dirección:</td>
        <td><input "hidden" name="direccion" size="35" maxlength="100" type="text"></td>
      </tr>
      <tr>
      <td>Código Postal:</td>
        <td><input "hidden" name="codigopostal" size="35" maxlength="100" type="text"></td>
      </tr>
      <tr>
      
        <td>Comentarios:</td>
        <td><textarea name="comentario" cols="50" rows="5" wrap="soft"></textarea></td>
      </tr>
      <tr>
        <td></td>
        <td> 
        <table width: 100%;" border="0" cellpadding="2" cellspacing="2">
          <tbody>
            <tr>
              <td style="width: 10%;"><input name="reset" value="Borrar datos" type="reset"></td>
              <td style="width: 10%;"><input name="submit" value="Enviar datos" type="submit"></td>
              <td style="width: 80%;"></td>
            </tr>
          </tbody>
        </table>
        </td>
      </tr>
    </tbody>
  </table>
</form>




</body>
</html>

y este es el que envia el email


Código PHP:
<?php
 



if(($_POST["nombre"]) && isset($_POST["apellido"])&& isset($_POST["tel"])&& isset($_POST["email"]) && isset($_POST["direccion"]) && isset($_POST["codigopostal"])&& isset($_POST["comentario"])){
    



// Inicializamos una variable interruptor a cero.
// Dicha variable no cambiará de valor, a no ser que se produzca un error.
$error=0;
// Comprobamos el valor de submit
if (!empty($submit)) { 



// Agrupamos los datos introducidos
$to "[email protected]";
$subject "Mensaje Enviado";
$contenido .= "Nombre: ".$_POST["nombre"]."\n";
$contenido .= "Apellidos: ".$_POST["apellido"]."\n";
$contenido .= "Telefono: ".$_POST["tel"]."\n";
$contenido .= "E-mail: ".$_POST["email"]."\n";
$contenido .= "Dirección: ".$_POST["direccion"]."\n";

$contenido .= "Comentario: ".$_POST['comentario']."\n";

$header "From: [email protected]\nReply-To:"
.
ini_set("sendmail_from""[email protected]");
$_POST["email"]."\n";
$header .= "Mime-Version: 1.0\n";
$header .= "Content-type: text/html; charset=iso-8859-1\r\n";
// Enviamos el mensaje
if(mail($to,$subject,$contenido,$header)) {
echo 
"Mail Enviado.";
}
}
?>
<?php
}

else { 
// Si algo falla: ERROR
$error=1;
?>
ERROR: Su mensaje no se ha podido enviar por un problema en el servidor.Todos los campos son obligatorios.


<?php
}
if (
$error)
{
?>

<form>
<input type="button" value="Volver al formulario" 
onclick="javascript:history.back()">
</form>

<noscript>Utilice el BOTON ATRAS del navegador para volver</noscript>
<?php
}

else { 
//Si submit está vacío: ERROR
}
?>