Visualizzazione dei risultati da 1 a 5 su 5
  1. #1
    Utente di HTML.it
    Registrato dal
    Jan 2003
    Messaggi
    1,100

    controllo "while" su form mail

    ciao!

    ho implementato un form html per l'invio di un modulo via mail; la pagina html invia ad uno script in php le info da inviare nel corpo della mail del destinatario
    nel form è possibile duplicare una riga della tabella con tre campi, denominati
    campo_uno campo_due campo_tre
    man mano che si aggiungono righe, i campi vengono nominati come:
    campo_uno1 campo_due1 campo_tre1
    campo_uno2 campo_due2 campo_tre2
    etc....

    ho provato ad implementare un ciclo "while" nello script php per aggiungere automaticamente i campi addizionali, ma ho dei problemi....
    chi è così di buon cuore da darmi una mano?
    ufino

  2. #2
    Utente di HTML.it
    Registrato dal
    Jan 2003
    Messaggi
    1,100
    help please!
    ufino

  3. #3
    ciao ufino, ci ritroviamo di qua

    prova a postare il codice PHP che vediamo cosa c'e' che non va

  4. #4
    I dati in post ti arrivano in array quindi è sufficiente che tu faccia:

    $messaggio="";
    foreach ($_POST as $nome=>$valore){
    $messaggio .=$nome." : ".$valore;
    }

    In questo modo otterrai tutti i dati che ti servono indipendentemente dal tuo form.
    Stai attento alcuni dati in post potrebbero non interessarti come submit

    Puoi utilizzare la funzione unset(); per eliminare le variabili POST


  5. #5
    Utente di HTML.it
    Registrato dal
    Jan 2003
    Messaggi
    1,100
    ciao Raven

    il codice è questo:
    --------------------------------------
    <?php


    //this is kinda plain english
    //basicly it check's the recipient address...if you where wondering what it does

    // $recipient_in = split(',',$recipient);
    //for ($i=0;$i<count($recipient_in);$i++) {
    // $recipient_to_test = trim($recipient_in[$i]);
    // if (!eregi("^[_\\.0-9a-z-]+@([0-9a-z][0-9a-z-]+\\.)+[a-z]{2,3}$", $recipient_to_test)) {
    // print_error("I NEED A VALID RECIPIENT EMAIL ADDRESS ($recipient_to_test) TO CONTINUE");
    // }
    //S}
    //change require to required
    if ($required)
    $require = $required;

    if ($require) {
    //this is kinda plain english
    $require = ereg_replace( " +", "", $require);
    $required = split(",",$require);
    for ($i=0;$i<count($required);$i++) {
    $string = trim($required[$i]);
    if((!(${$string})) || (!(${$string}))) {
    if ($missing_fields_redirect) {
    header ("Location: $missing_fields_redirect");
    exit;
    }
    $require;
    $missing_field_list .= "You Did Not Enter: $required[$i]
    \n";
    }

    /* for php programmers only
    if variables are'nt gettin sent you can just
    uncomment this line and include this code which will get all variables sent
    in the form and put them all in the message variable */

    //$message = parse_form($HTTP_POST_VARS);

    /* if underscore's dont appear, put them in, its just may editor is SHIT */

    /*
    i dont use this because i need some variables and its not very reliable this was used in v1.0 & v1.1 */

    }
    }

    //if no subject use $othersub
    if (!$subject)
    $subject = "$othersub";
    //if no $othersub & no $subject use form submission as subject
    else if ((!$othersub) && (!$subject))
    $subject = "Form Submission";

    //Send E-mail
    //other = if you added a extra field to the form call them other - other4
    // dont worry bout the $other variables if you dont have them in the form nothing will show in the email

    mail("$recipient","$subject","

    -- Messaggio inviato tramite il modulo contatti --
    Da:
    $name

    e-mail:
    $email

    Telefono:
    $telefono

    Quantità:
    $campo_uno
    Modello:
    $campo_due
    Descrizione:
    $campo_tre


    ","From: $name <$email>");
    // END send e-mail


    // INVIO DELLA MAIL
    if(@mail($to, $subject, $body, $headers)) { // SE L'INOLTRO E' ANDATO A BUON FINE...

    header("location: conferma.htm");

    } else {// ALTRIMENTI...

    header("location: problema.htm");

    }

    ?>
    --------------------------------------

    Silverwings, puoi darmi maggiori info su come realizzare quanto suggerisci?
    ufino

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 © 2025 vBulletin Solutions, Inc. All rights reserved.