Visualizzazione dei risultati da 1 a 3 su 3

Discussione: carrello php

  1. #1
    Utente di HTML.it
    Registrato dal
    May 2008
    Messaggi
    40

    carrello php

    carrello in php

    --------------------------------------------------------------------------------

    ciao a tutti ...
    sto provando a costruire un carrello con codice preso un po in rete un po' modificato da me
    le pagine sono
    index.php
    carrello.php
    funzioni.php
    invioemail.php (questo e' il PROBLEMA)
    mail.php(che processa il post PROBLEMA)

    sapete darmi una dritta per postare il tutto ad un email

    funzioni.php
    <?php
    function usaCarrello()
    {
    $carrello = $_SESSION['carrello'];
    if (!$carrello)
    {
    return 'Carrello vuoto.
    ';
    }else{
    $prodotti = @explode(',',$carrello);
    return 'Ci sono <a href="carrello.php">'.
    @count($prodotti). ' prodotti nel carrello.</a>
    ';
    }
    }
    function mostraCarrello()
    {
    global $db;
    $carrello = $_SESSION['carrello'];
    $somma = 0;
    if ($carrello)
    {
    $prodotti = @explode(',',$carrello);
    $acquisti = array();
    foreach ($prodotti as $prodotto)
    {
    $acquisti[$prodotto] = (@isset($acquisti[$prodotto])) ? $acquisti[$prodotto] + 1 : 1;
    }
    $result[] = '<form action="carrello.php?action=aggiorna" method="post" id="cart">';
    $result[] = '<table>';
    foreach ($acquisti as $id=>$quantita)
    {
    $sql = 'SELECT * FROM prodotti WHERE id = '.$id;
    $res = $db->query($sql);
    $f = $res->fetch();
    @extract($f);
    $result[] = '<tr>';
    $result[] = '<td>Can cella</td>';
    $result[] = '<td>
    [img]images_resize/'.$f['immagine_small'].'[/img]</td>';
    $result[] = '<td>
    <span class="testo">'.$nome.'</span>
    <span class="intestazioni">Descrizione</span><span class="testo"> :' .$marca.'</span></td>';
    $result[] = '<td>&euro;'.$prezzo.'</td>';
    $result[] = '<td><input type="text" name="quantita'.$id.'" value="'.$quantita.'" size="3"></td>';
    $result[] = '<td>&euro;'.($prezzo * $quantita).'</td>';
    $somma += $prezzo * $quantita;
    $result[] = '</tr>';
    }
    $result[] = '</table>';
    $result[] = 'Totale: <span class="tot">&euro;'.$somma.'</span></br>';
    $result[] = '<button type="submit">Aggiorna il carrello</button></br></br>';
    $result[] = 'ORDINA';
    $result[] = '</form>';
    }else{
    $result[] = 'Carrello vuoto.
    ';
    }
    return @join('',$result);
    }
    ?>


    <?php
    //aggiunte per vedere i prodotti ordinati in invioemail.php
    function riassunto()
    {
    $carrello = $_SESSION['carrello'];
    if (!$carrello)
    {
    return 'Carrello vuoto.
    ';
    }else{
    $prodotti = @explode(',',$carrello);
    return 'Stai acquistando :'.
    @count($prodotti). ' prodotti.</a>
    ';
    }
    }
    function riassunto_1()
    {
    global $db;
    $carrello = $_SESSION['carrello'];
    $somma = 0;
    if ($carrello)
    {
    $prodotti = @explode(',',$carrello);
    $acquisti = array();
    foreach ($prodotti as $prodotto)
    {
    $acquisti[$prodotto] = (@isset($acquisti[$prodotto])) ? $acquisti[$prodotto] + 1 : 1;
    }
    $result[] = '<form action="carrello.php?action=aggiorna" method="post" id="cart">';
    $result[] = '<table>';
    foreach ($acquisti as $id=>$quantita)
    {
    $sql = 'SELECT * FROM prodotti WHERE id = '.$id;
    $res = $db->query($sql);
    $f = $res->fetch();
    @extract($f);
    $result[] = '<tr>';
    $result[] = '<td><span class="testo">'.$nome.'</span></td>';
    $result[] = '<td>&euro;'.$prezzo.'</td>';
    $result[] = '<td><input type="text" name="quantita'.$id.'" value="'.$quantita.'" size="3"></td>';
    $result[] = '<td>&euro;'.($prezzo * $quantita).'</td>';
    $somma += $prezzo * $quantita;
    $result[] = '</tr>';
    }
    $result[] = '</table>';
    $result[] = 'Totale: <span class="tot">&euro;'.$somma.'</span></br>';
    $result[] = '</form>';
    }else{
    $result[] = 'Carrello vuoto.
    ';
    }
    return @join('',$result);
    }
    ?>

    invioemail.php
    <form name="form1" method="post" action="mail.php">
    <table width="523" align="center" cellpadding="3" >
    <tr>
    <td colspan="2" align="center"><table width="176" border="0" cellspacing="0" cellpadding="2">
    <tr>
    <td width="182" class="testo"></td>
    </tr>
    </table></td>
    </tr>
    <tr>
    <td width="23%" align="right"><strong class="testo">Nome :::[/b]</td>
    <td><input name="nome" type="text" class="form" size="40"></td>
    </tr>
    <tr>
    <td align="right"><strong class="testo">Cognome :::[/b]</td>
    <td><input name="cognome" type="text" class="form" size="40"></td>
    </tr>
    <tr>
    <td align="right"><strong class="testo">Localita' ::: [/b]</td>
    <td><input name="localita" type="text" class="form" id="localita" size="40"></td>
    </tr>
    <tr>
    <td align="right"><strong class="testo"> Email ::: [/b]</td>
    <td><input name="email" type="text" class="form" id="email" size="40"></td>
    </tr>
    <tr>
    <td align="right" class="testo">Indirizzo:::</td>
    <td><input name="indirizzo" type="text" class="form" size="60" id="indirizzo" /></td>
    </tr>
    <tr>
    <td align="right"><strong class="testo">Cap :::[/b]</td>
    <td><input name="cap" type="text" class="form" size="25" id="cap"></td>
    </tr>
    <tr>
    <td align="right"><strong class="testo">Telefono :::[/b]</td>
    <td><input name="telefono" type="text" class="form" size="40" id="telefono" /></td>
    </tr>
    <tr>
    <td align="right"></td>
    <td class="testo">metodo di pagamento : contrassegno</td>
    </tr>
    <tr>
    <td colspan="2"><table width="324" border="0" align="center" cellpadding="2" cellspacing="0">
    <tr>
    <td colspan="3" align="center">

    <span class="privacy">Si accetto condizioni sulla privacy dei dati : </span>
    <input name="si" type="radio" value="si" />




    </p> </td>
    </tr>
    <tr>
    <td width="68" align="right" class="testo"></td>
    <td width="45"><label></label></td>
    <td width="165"><label></label></td>
    </tr>

    </table></td>
    </tr>
    <tr>
    <td height="40" colspan="2"><div align="center">
    <table width="381" border="0" align="left" cellpadding="2" cellspacing="0">
    <tr>
    <td width="214" align="right"><input name="Submit" type="submit" class="pulsanti" value="Invia modulo" onclick="return checkData()" /></td>
    <td width="30"></td>
    <td width="125"><label>
    <input name="Submit2" type="reset" class="pulsanti" value="Ripristina modulo" />
    </label></td>
    </tr>
    </table>
    </div></td>
    </tr>
    <tr>
    <td height="40" colspan="2">Riassunto merce comprata :

    <?php
    @session_start();
    @require('mysql.php');
    @require('config.php');
    @require('funzioni.php');
    //le due funzioni create
    ?>
    <?php
    echo riassunto();
    ?>
    <?php
    echo riassunto_1();
    ?>
    Torna allo shop


    </td>
    </tr>
    </table>
    </form>


    mail.php
    <?php
    // L'INDIRIZZO DEL DESTINATARIO DELLA MAIL
    $to = "info......it";
    // IL SOGGETTO DELLA MAIL
    $subject = "*Modulo proveniente dal sito xxx.mar.it";
    // COSTRUZIONE DEL CORPO DEL MESSAGGIO
    $body = "Contenuto:\n\n";
    $body .= "Dati personali ;
    nome: " . trim(stripslashes($_POST["nome"])) . "\n";
    $body .= "cognome: " . trim(stripslashes($_POST["cognome"])) . "\n";
    $body .= "Localita': " . trim(stripslashes($_POST["localita"])) . "\n";
    $body .= "Email: " . trim(stripslashes($_POST["email"])) . "\n";
    $body .= "Indirizzo: " . trim(stripslashes($_POST["indirizzo"])) . "\n";
    $body .= "Cap: " . trim(stripslashes($_POST["cap"])) . "\n";
    $body .= "Telefono: " . trim(stripslashes($_POST["telefono"])) . "\n";
    $body .= "si: " . trim(stripslashes($_POST["si"])) . "\n";
    $result .= "nome: " . trim(stripslashes($_POST['nome'])) . "\n";
    $result .= "prezzo: " . trim(stripslashes($_POST['prezzo'])) . "\n";
    $result .= "quantita': " . trim(stripslashes($_POST['quantita'])) . "\n";
    $somma= "somma: " . trim(stripslashes($_POST['prezzo' * 'quantita'])) . "\n";
    // queste non sono assolutamente sicuro.....
    if(@mail($to, $subject, $body,$result,$somma))
    ?>


    grazie dell'aiuto.....

  2. #2
    Utente di HTML.it L'avatar di ade_v
    Registrato dal
    Jan 2001
    Messaggi
    459
    Leggiti

    http://it2.php.net/manual/it/function.mail.php

    tu scrivi
    Codice PHP:
    @mail($to$subject$body,$result,$somma
    ma
    Codice PHP:
    $result 
    e
    Codice PHP:
    $somma 
    cosa centrano ?

    al posto di
    Codice PHP:
    $result 
    ci vanno le intestazioni della mail, gli header. e
    Codice PHP:
    $somma 
    non viene interpretato come parametro.

    Codice PHP:
    $result 
    e
    Codice PHP:
    $somma 
    vanno inglobati in
    Codice PHP:
    $body 
    ade_v@yahoo.it

    Fletto i muscoli e sono nel vuoto

    Se inviate messaggi privati, avvisatemi sul forum...

  3. #3
    Utente di HTML.it
    Registrato dal
    May 2008
    Messaggi
    40

    esatto

    si esatto pero' come passo i dati a mail.php da inviomail.php?
    io avevo provato cosi'

    <?php

    // L'INDIRIZZO DEL DESTINATARIO DELLA MAIL
    $to = "info@max....it";

    // IL SOGGETTO DELLA MAIL
    $subject = "*Modulo proveniente dal sito www.max...it";



    // COSTRUZIONE DEL CORPO DEL MESSAGGIO
    $body = "Contenuto:\n\n";
    $body .= "Dati personali ;
    nome: " . trim(stripslashes($_POST["nome"])) . "\n";
    $body .= "cognome: " . trim(stripslashes($_POST["cognome"])) . "\n";
    $body .= "Localita': " . trim(stripslashes($_POST["localita"])) . "\n";
    $body .= "Email: " . trim(stripslashes($_POST["email"])) . "\n";
    $body .= "Indirizzo: " . trim(stripslashes($_POST["indirizzo"])) . "\n";
    $body .= "Cap: " . trim(stripslashes($_POST["cap"])) . "\n";
    $body .= "Telefono: " . trim(stripslashes($_POST["telefono"])) . "\n";
    $body .= "Accetta privacy: " . trim(stripslashes($_POST["si"])) . "\n";
    $body .= "nome prodotto: " . trim(stripslashes($_POST["nome"])) . "\n";
    $body .= "prezzo: " . trim(stripslashes($_POST["prezzo"])) . "\n";
    ecc................

    @session_start();
    @require('mysql.php');
    @require('config.php');
    @require('funzioni.php');


    riassunto();

    riassunto_1();

    // INVIO DELLA MAIL
    if(@mail($to, $subject, $body))
    ?>

    PER0' NON FUNZIONA
    come faccio a trasportare tutti i miei dati da invioemail.php a mail.php?
    THANKS

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2026 vBulletin Solutions, Inc. All rights reserved.