problema con form mail

Supporto stili in generale.
Rispondi
alfmayster
Utente
Utente
Messaggi: 1
Iscritto il: 22/07/2015, 22:57

problema con form mail

Messaggio da alfmayster » 22/07/2015, 23:15

Salve a tutti
questo è il mio primo post in questo fantastico portale..
avrei il seguente problema...premetto non sono per niente un esperto in php anzi...mi occupo piu di html e css
ho creato un form mail da webformgenerator.eu e fin qui tutto ok, l'ho settato alla bisogna in modo che risponda in italiano agli errori ecc..ecc or mi sorge un problemino ..all'interno del form c'è la possibilitaà di selezionare dei modelli di auto...ora il problema e che se ne seleziono uno solo ok tutto bene...quando ne voglio selezionare piu di uno tramite checkbox mi invia per mail soltanto un valore selezionato vi posto il codice dell interfaccia e del modulo di invio psero che qualcuno sappia risolvermi questo problema che credo sia banale...ma non avendo esperienza non so come risolvere...grazie anticipatamente a tutti quelli che vorranno aiutarmi 8-)

codice maschera di inserimento

Codice: Seleziona tutto

<!--
 Created with Webformgenerator by easyclick.ch
 www.easyclick.ch
 -->

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title></title>
    <link href="css/style.css" media="screen" rel="stylesheet" type="text/css"/>
    <link href="css/uniform.css" media="screen" rel="stylesheet" type="text/css"/>
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js"></script>
    <script type="text/javascript" src="js/jquery.tools.js"></script>
    <script type="text/javascript" src="js/jquery.uniform.min.js"></script>
    <script type="text/javascript" src="js/main.js"></script>
</head>
<body>

<div class="TTWForm-container">
     
     
     <div id="form-title" class="form-title field">
          <h2>
               L'AutoSposa_<strong>VERGARA</strong> - PREVENTIVO On-Line
          </h2>
     </div>
     
     
     <form action="process_form.php" class="TTWForm" method="post" novalidate="">
          
          
          <div id="field1-container" class="field f_100">
               <label for="field1">
                    Nome & Cognome
               </label>
               <input type="text" name="nome" id="field1" required="required">
          </div>
          
          
          <div id="field3-container" class="field f_100">
               <label for="field3">
                    Numero di telefono
               </label>
               <input type="text" name="telefono" id="field3" required="required">
          </div>
          
          
          <div id="field4-container" class="field f_100">
               <label for="field4">
                    Indirizzo Mail
               </label>
               <input type="email" name="mail" id="field4" required="required">
          </div>
          
          
          <div id="field5-container" class="field f_100 radio-group required">
               <label for="field5-1">
                    Tipo di noleggio
               </label>
               
               
               <div class="option clearfix">
                    <input type="radio" name="noleggio" id="field5-1" value="Matrimonio">
                    <span class="option-title">
                         Matrimonio
                    </span>
               </div>
               
               
               <div class="option clearfix">
                    <input type="radio" name="noleggio" id="field5-2" value="Altro evento ( Pubblicità, Addio al Celibato/Nubilato, Compleanno, Anniversario, Transfer ) ">
                    <span class="option-title">
                         Altro evento ( Pubblicità, Addio al Celibato/Nubilato, Compleanno, Anniversario,
                         Transfer )
                    </span>
               </div>
          </div>
          
          
          <div id="field15-container" class="field f_100">
               <label for="field15">
                    Località Casa
               </label>
               <input type="text" name="ind_casa" id="field15">
          </div>
          
          
          <div id="field16-container" class="field f_100">
               <label for="field16">
                    Località Chiesa
               </label>
               <input type="text" name="ind_chiesa" id="field16">
          </div>
          
          
          <div id="field17-container" class="field f_100">
               <label for="field17">
                    Località Ristorante
               </label>
               <input type="text" name="ind_ristorante" id="field17">
          </div>
          
          
          <div id="field6-container" class="field f_100 radio-group required">
               <label for="field6-1">
                    Fascia oraria del noleggio
               </label>
               
               
               <div class="option clearfix">
                    <input type="radio" name="fascia" id="field6-1" value="Mattina">
                    <span class="option-title">
                         Mattina
                    </span>
               </div>
               
               
               <div class="option clearfix">
                    <input type="radio" name="fascia" id="field6-2" value="Pomeriggio">
                    <span class="option-title">
                         Pomeriggio
                    </span>
               </div>
          </div>
          
          
          <div id="field8-container" class="field f_100">
               <label for="field8">
                    Data del noleggio
               </label>
               <input class="ttw-date date" id="field8" maxlength="524288" name="data"
               required="" size="20" tabindex="0" title="" min="">
          </div>
          
          
          <div id="field9-container" class="field f_100">
               <label for="field9">
                    Richieste speciali
               </label>
               <textarea rows="5" cols="20" name="richieste" id="field9"></textarea>
          </div>
          
          
          <div id="field10-container" class="field checkbox-group required f_100">
               <label for="field10-1">
                    Scegli la tua vettura
               </label>
               
               
               <div class="option clearfix">
                    <input type="checkbox" name="auto" id="field10-1" value="500 Aperitivo ">
                    <span class="option-title">
                         500 Aperitivo
                    </span>
                    <br>
               </div>
               
               
               <div class="option clearfix">
                    <input type="checkbox" name="auto" id="field10-2" value="Torpedo ">
                    <span class="option-title">
                         Torpedo
                    </span>
                    <br>
               </div>
               
               
               <div class="option clearfix">
                    <input type="checkbox" name="auto" id="field10-3" value="Rolls Royce Princess ">
                    <span class="option-title">
                         Rolls Royce Princess
                    </span>
                    <br>
               </div>
               
               
               <div class="option clearfix">
                    <input type="checkbox" name="auto" id="auto-4" value="Rolls Royce Royal Scheerline ">
                    <span class="option-title">
                         Rolls Royce Royal Scheerline
                    </span>
                    <br>
               </div>
               
               
               <div class="option clearfix">
                    <input type="checkbox" name="auto" id="auto-5" value="Bentley S1 ">
                    <span class="option-title">
                         Bentley S1
                    </span>
                    <br>
               </div>
               
               
               <div class="option clearfix">
                    <input type="checkbox" name="auto" id="auto-6" value="Taxi Inglese - Bianco ">
                    <span class="option-title">
                         Taxi Inglese - Bianco
                    </span>
                    <br>
               </div>
               
               
               <div class="option clearfix">
                    <input type="checkbox" name="auto" id="auto-7" value="Taxi Inglese - Nero ">
                    <span class="option-title">
                         Taxi Inglese - Nero
                    </span>
                    <br>
               </div>
               
               
               <div class="option clearfix">
                    <input type="checkbox" name="auto" id="auto-8" value="Excalibur SERIE 3 ">
                    <span class="option-title">
                         Excalibur SERIE 3
                    </span>
                    <br>
               </div>
               
               
               <div class="option clearfix">
                    <input type="checkbox" name="auto" id="auto-9" value="Excalibur SERIE 4 ">
                    <span class="option-title">
                         Excalibur SERIE 4
                    </span>
                    <br>
               </div>
               
               
               <div class="option clearfix">
                    <input type="checkbox" name="auto" id="auto-10" value="Excalibur 4 Porte ">
                    <span class="option-title">
                         Excalibur 4 Porte
                    </span>
                    <br>
               </div>
               
               
               <div class="option clearfix">
                    <input type="checkbox" name="auto" id="auto-11" value="MG Lafer 2 Posti ">
                    <span class="option-title">
                         MG Lafer 2 Posti
                    </span>
                    <br>
               </div>
               
               
               <div class="option clearfix">
                    <input type="checkbox" name="auto" id="auto-12" value="Maggiolino Cabrio ">
                    <span class="option-title">
                         Maggiolino Cabrio
                    </span>
                    <br>
               </div>
               
               
               <div class="option clearfix">
                    <input type="checkbox" name="auto" id="auto-13" value="New Beetle Cabrio ">
                    <span class="option-title">
                         New Beetle Cabrio
                    </span>
                    <br>
               </div>
               
               
               <div class="option clearfix">
                    <input type="checkbox" name="auto" id="auto-14" value="Limousine Lincoln ">
                    <span class="option-title">
                         Limousine Lincoln
                    </span>
                    <br>
               </div>
               
               
               <div class="option clearfix">
                    <input type="checkbox" name="auto" id="auto-15" value="Limousine Hummer ">
                    <span class="option-title">
                         Limousine Hummer
                    </span>
                    <br>
               </div>
               
               
               <div class="option clearfix">
                    <input type="checkbox" name="auto" id="auto-16" value="BMW Cabrio SERIE M1 Sport ">
                    <span class="option-title">
                         BMW Cabrio SERIE M1 Sport
                    </span>
                    <br>
               </div>
               
               
               <div class="option clearfix">
                    <input type="checkbox" name="auto" id="auto-17" value="Mercedes CLASSE E Cabrio ">
                    <span class="option-title">
                         Mercedes CLASSE E Cabrio
                    </span>
                    <br>
               </div>
               
               
               <div class="option clearfix">
                    <input type="checkbox" name="auto" id="auto-18" value="Jaguar XF ">
                    <span class="option-title">
                         Jaguar XF
                    </span>
                    <br>
               </div>
               
               
               <div class="option clearfix">
                    <input type="checkbox" name="auto" id="auto-19" value="Jaguar XJ ">
                    <span class="option-title">
                         Jaguar XJ
                    </span>
                    <br>
               </div>
               
               
               <div class="option clearfix">
                    <input type="checkbox" name="auto" id="auto-20" value="Porsche Panamera - Nero ">
                    <span class="option-title">
                         Porsche Panamera - Nero
                    </span>
                    <br>
               </div>
               
               
               <div class="option clearfix">
                    <input type="checkbox" name="auto" id="auto-21" value="Porsche Panamera - Blue ">
                    <span class="option-title">
                         Porsche Panamera - Blue
                    </span>
                    <br>
               </div>
               
               
               <div class="option clearfix">
                    <input type="checkbox" name="auto" id="auto-22" value="Porsche Panamera - Bianco ">
                    <span class="option-title">
                         Porsche Panamera - Bianco
                    </span>
                    <br>
               </div>
               
               
               <div class="option clearfix">
                    <input type="checkbox" name="auto" id="auto-23" value="Maserati Ghibli Q4 Quattroporte - Bianco ">
                    <span class="option-title">
                         Maserati Ghibli Q4 Quattroporte - Bianco
                    </span>
                    <br>
               </div>
               
               
               <div class="option clearfix">
                    <input type="checkbox" name="auto" id="auto-24" value="Maserati Q4 Quattroporte - Bianco ">
                    <span class="option-title">
                         Maserati Q4 Quattroporte - Bianco
                    </span>
                    <br>
               </div>
               
               
               <div class="option clearfix">
                    <input type="checkbox" name="auto" id="auto-25" value="Maserati Q4 Quattroporte - Blu ">
                    <span class="option-title">
                         Maserati Q4 Quattroporte - Blu
                    </span>
                    <br>
               </div>
               
               
               <div class="option clearfix">
                    <input type="checkbox" name="auto" id="auto-26" value="Maserati Quattroporte GTS - Bianco ">
                    <span class="option-title">
                         Maserati Quattroporte GTS - Bianco
                    </span>
                    <br>
               </div>
               
               
               <div class="option clearfix">
                    <input type="checkbox" name="auto" id="auto-27" value="Maserati Quattroporte GTS - Blue ">
                    <span class="option-title">
                         Maserati Quattroporte GTS - Blue
                    </span>
                    <br>
               </div>
               
               
               <div class="option clearfix">
                    <input type="checkbox" name="auto" id="auto-28" value="Jaquar S-type ">
                    <span class="option-title">
                         Jaquar S-type
                    </span>
                    <br>
               </div>
               
               
               <div class="option clearfix">
                    <input type="checkbox" name="auto" id="auto-29" value="Mercedes CLK Cabrio ">
                    <span class="option-title">
                         Mercedes CLK Cabrio
                    </span>
                    <br>
               </div>
               
               
               <div class="option clearfix">
                    <input type="checkbox" name="auto" id="auto-30" value="Mercedes CLASSE S ">
                    <span class="option-title">
                         Mercedes CLASSE S
                    </span>
                    <br>
               </div>
               
               
               <div class="option clearfix">
                    <input type="checkbox" name="auto" id="auto-31" value="Mercedes CLS ">
                    <span class="option-title">
                         Mercedes CLS
                    </span>
                    <br>
               </div>
               
               
               <div class="option clearfix">
                    <input type="checkbox" name="auto" id="auto-32" value="BMW X6 ">
                    <span class="option-title">
                         BMW X6
                    </span>
                    <br>
               </div>
               
               
               <div class="option clearfix">
                    <input type="checkbox" name="auto" id="auto-33" value="Ferrari California">
                    <span class="option-title">
                         Ferrari California
                    </span>
                    <br>
               </div>
               
               
               <div class="option clearfix">
                    <input type="checkbox" name="auto" id="auto-34" value="Ferrari F430">
                    <span class="option-title">
                         Ferrari F430
                    </span>
                    <br>
               </div>
               
               
               <div class="option clearfix">
                    <input type="checkbox" name="auto" id="auto-35" value="Pulmino Volkswagen T2">
                    <span class="option-title">
                         Pulmino Volkswagen T2
                    </span>
                    <br>
               </div>
          </div>
          
          
          <div id="form-submit" class="field f_100 clearfix submit">
               <input type="submit" value="Invia">
          </div>
     </form>
</div>

</body>
</html>


codice processo logico php

Codice: Seleziona tutto

<?php
/**
 * Created with WebFormGenerator.eu
 * Powered by www.easyclick.ch
 */

$form = new ProcessForm();
$form->field_rules = array(
	'nome'=>'required',
	'telefono'=>'required',
	'mail'=>'email|required',
	'noleggio'=>'required',
	'ind_casa'=>'',
	'ind_chiesa'=>'',
	'ind_ristorante'=>'',
	'fascia'=>'required',
	'data'=>'required',
	'richieste'=>'',
	'auto'=>'required'
);
$form->validate();

class ProcessForm
{
    public $field_rules;
    public $error_messages;
    public $fields;
    private $error_list;
    private $is_xhr;





    function __construct()
    {
        $this->error_messages = array(
            'required' => 'Questo campo è obbligatorio',
            'email' => 'Inserire un indirizzo di posta valido',
            'number' => 'Please enter a numeric value',
            'url' => 'Please enter a valid URL',
            'pattern' => 'Please correct this value',
            'min' => 'Please enter a value larger than the minimum value',
            'max' => 'Please enter a value smaller than the maximum value'
        );

        $this->field_rules = array();
        $this->error_list = '';
        $this->fields = $_POST;
        $this->is_xhr = $this->xhr();
    }





    function validate()
    {
        if (!empty($this->fields))
        {
            //Validate each of the fields
            foreach ($this->field_rules as $field => $rules)
            {
                $rules = explode('|', $rules);

                foreach ($rules as $rule)
                {
                    $result = null;

                    if (isset($this->fields[$field]))
                    {
                        $param = false;

                        if (preg_match("/(.*?)\[(.*?)\]/", $rule, $match))
                        {
                            $rule = $match[1];
                            $param = $match[2];
                        }

                        $this->fields[$field] = $this->clean($this->fields[$field]);

                        //if the field is a checkbox group create string
                        if (is_array($this->fields[$field]))
                            $this->fields[$field] = implode(', ', $this->fields[$field]);

                        // Call the function that corresponds to the rule
                        if (!empty($rule))
                            $result = $this->$rule($this->fields[$field], $param);

                        // Handle errors
                        if ($result === false)
                            $this->set_error($field, $rule);
                    }
                }
            }

            if (empty($this->error_list))
            {
                if ($this->is_xhr)
                    echo json_encode(array('status' => 'success'));

                $this->process();
            }
            else
            {
                if ($this->is_xhr)
                    echo json_encode(array('status' => 'invalid', 'errors' => $this->error_list));
                else echo $this->error_list;
            }
        }
    }





    function process()
    {
         /**
         * SUCCESS!!
         * There were no errors in the form. Insert your processing logic here (i.e. send an email, save to a
         * database etc.
         *
         * All of the submitted fields are available in the $this->fields variable.
         *
         * Example code to mail the results of the form:
         *
         * IMPORTANT - PLEASE READ:
         * 1. YOU MUST UNCOMMENT THE CODE FOR IT TO WORK.
         *    - This means removing the '//' in front of each line.
         *    - If you do not know what php comments are see here: http://php.net/manual/en/language.basic-syntax.comments.php
         *
         * 2. YOU CAN ENTER ANY EMAIL ADDRESS IN THE $from VARIABLE.
         *    - This is the address that will show in the From column in your mail application.
         *    - If your form contains an email field, and you want to use that value as the $from variable, you can set $from = $this->fields['name of your email field'];
         *    - As stated in the description on codecanyon, this code does not mail attachments. Google 'php html email attachments' for information on how to do this
         */



          $msg = "Informazioni Preventivo: \n\n";
          foreach($this->fields as $key => $field)
                $msg .= "$key :  $field \n";

          $to = 'info@lautosposa.it';
          $subject = 'Richiesta di preventivo';
          $from = 'info@lautosposa.it';

          mail($to, $subject, $msg, "From: $from\r\nReply-To: $from\r\nReturn-Path: $from\r\n");


    }



    function set_error($field, $rule)
    {
        if ($this->is_xhr)
        {
            $this->error_list[$field] = $this->error_messages[$rule];
        }
        else $this->error_list .= "<div class='error'>$field: " . $this->error_messages[$rule] . "</div>";
    }





    function xhr()
    {
        return (!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') ? true : false;
    }





    /** Validation Functions */
    function required($str, $val = false)
    {

        if (!is_array($str))
        {
            $str = trim($str);
            return ($str == '') ? false : true;
        }
        else
        {
            return (!empty($str));
        }
    }





    function email($str)
    {
        return (!preg_match("/^(?!(?:(?:\\x22?\\x5C[\\x00-\\x7E]\\x22?)|(?:\\x22?[^\\x5C\\x22]\\x22?)){255,})(?!(?:(?:\\x22?\\x5C[\\x00-\\x7E]\\x22?)|(?:\\x22?[^\\x5C\\x22]\\x22?)){65,}@)(?:(?:[\\x21\\x23-\\x27\\x2A\\x2B\\x2D\\x2F-\\x39\\x3D\\x3F\\x5E-\\x7E]+)|(?:\\x22(?:[\\x01-\\x08\\x0B\\x0C\\x0E-\\x1F\\x21\\x23-\\x5B\\x5D-\\x7F]|(?:\\x5C[\\x00-\\x7F]))*\\x22))(?:\\.(?:(?:[\\x21\\x23-\\x27\\x2A\\x2B\\x2D\\x2F-\\x39\\x3D\\x3F\\x5E-\\x7E]+)|(?:\\x22(?:[\\x01-\\x08\\x0B\\x0C\\x0E-\\x1F\\x21\\x23-\\x5B\\x5D-\\x7F]|(?:\\x5C[\\x00-\\x7F]))*\\x22)))*@(?:(?:(?!.*[^.]{64,})(?:(?:(?:xn--)?[a-z0-9]+(?:-[a-z0-9]+)*\\.){1,126}){1,}(?:(?:[a-z][a-z0-9]*)|(?:(?:xn--)[a-z0-9]+))(?:-[a-z0-9]+)*)|(?:\\[(?:(?:IPv6:(?:(?:[a-f0-9]{1,4}(?::[a-f0-9]{1,4}){7})|(?:(?!(?:.*[a-f0-9][:\\]]){7,})(?:[a-f0-9]{1,4}(?::[a-f0-9]{1,4}){0,5})?::(?:[a-f0-9]{1,4}(?::[a-f0-9]{1,4}){0,5})?)))|(?:(?:IPv6:(?:(?:[a-f0-9]{1,4}(?::[a-f0-9]{1,4}){5}:)|(?:(?!(?:.*[a-f0-9]:){5,})(?:[a-f0-9]{1,4}(?::[a-f0-9]{1,4}){0,3})?::(?:[a-f0-9]{1,4}(?::[a-f0-9]{1,4}){0,3}:)?)))?(?:(?:25[0-5])|(?:2[0-4][0-9])|(?:1[0-9]{2})|(?:[1-9]?[0-9]))(?:\\.(?:(?:25[0-5])|(?:2[0-4][0-9])|(?:1[0-9]{2})|(?:[1-9]?[0-9]))){3}))\\]))$/iD", $str)) ? false : true;
    }





    function number($str)
    {
        return (!is_numeric($str)) ? false : true;
    }





    function min($str, $val)
    {
        return ($str >= $val) ? true : false;
    }





    function max($str, $val)
    {
        return ($str <= $val) ? true : false;
    }





    function pattern($str, $pattern)
    {
        return (!preg_match($pattern, $str)) ? false : true;
    }





    function clean($str)
    {
        $str = is_array($str) ? array_map(array("ProcessForm", 'clean'), $str) : str_replace('\\', '\\\\', strip_tags(trim(htmlspecialchars((get_magic_quotes_gpc() ? stripslashes($str) : $str), ENT_QUOTES))));
        return $str;
    }
}


?>

Avatar utente
Anto
Utente
Utente
Messaggi: 1106
Iscritto il: 04/02/2013, 21:53
Sesso: Maschio
Versione: 3.0.12
Server: UNIX/Linux
Contatta:

Re: problema con form mail

Messaggio da Anto » 28/07/2015, 13:38

Ciao, non ho capito bene il problema... Spiegati meglio! :)

Avatar utente
Sir Xiradorn
Grafico
Grafico
Messaggi: 1659
Iscritto il: 11/08/2009, 12:41
Sesso: Maschio
Versione: 3.2.0
Server: UNIX/Linux
PHP: 5.6.15
Database: MariaDB 10.1.9
Località: Lontano....
Contatta:

Re: problema con form mail

Messaggio da Sir Xiradorn » 29/07/2015, 18:04

Hai per i checkbox tutti lo stesso name. Cambialo in maniera che lo peschi come ti serve. Puoi usare una struttura del tipo chessò:
auto_*****

E prelevare il valore con un certo ciclo e smistarlo come ti serve
Sir Xiradorn
Immagine
~ XDojo - Xiradorn Lab Division - xiradorn.it ~
~ GitHub - XiradornLab ~

Immagine
Stargate - phpbb 3.0.x || 3.1.x || 3.2.x

Rispondi

Torna a “Supporto stili”

Chi c’è in linea

Visitano il forum: Yahoo [Bot] e 2 ospiti