Visualizzazione dei risultati da 1 a 3 su 3
  1. #1

    Form Invio Mail e Script PHP

    Salve ragazzi dcome da oggetto ho creato questo form:
    codice:
                <form method="post" name="email" action="mail.php">
                    <table border="0" cellspacing="0" cellpadding="0" width="100%">
                        <tbody>
                            <tr>
                                <td height="40" width="25%"><span>E-Mail:</span></td>
                                <td height="40" width="75%"><span><input style="BORDER-BOTTOM: 1px solid; BORDER-LEFT: 1px solid; FONT-FAMILY: Verdana,tahoma,Arial; BACKGROUND: rgb(255,255,255) 0% 50%; FONT-SIZE: 10px; BORDER-TOP: 1px solid; BORDER-RIGHT: 1px solid; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial" id="email" maxlength="120" size="50" name="email"/> </span></td>
    
                            </tr>
                            <tr>
                                <td height="35"><span>Nome:</span></td>
                                <td height="35"><span><input style="BORDER-BOTTOM: 1px solid; BORDER-LEFT: 1px solid; FONT-FAMILY: Verdana,tahoma,Arial; BACKGROUND: rgb(255,255,255) 0% 50%; FONT-SIZE: 10px; BORDER-TOP: 1px solid; BORDER-RIGHT: 1px solid; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial" id="first_name" maxlength="200" size="50" name="first_name"/> </span></td>
                            </tr>
                            <tr>
                                <td height="35"><span><span>Cognome:</span></span></td>
    
                                <td height="35"><span><span><input style="BORDER-BOTTOM: 1px solid; BORDER-LEFT: 1px solid; FONT-FAMILY: Verdana,tahoma,Arial; BACKGROUND: rgb(255,255,255) 0% 50%; FONT-SIZE: 10px; BORDER-TOP: 1px solid; BORDER-RIGHT: 1px solid; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial" id="last_name" maxlength="255" size="50" name="last_name"/> </span></span></td>
                            </tr>
                            <tr>
                                <td height="35"><span><span>Provincia:</span></span></td>
                                <td height="35"><span><span><span class="b10"><select size="1" name="provincia">
                                <option value="" selected="selected">Selezionare</option>
                                <option value="ag">Agrigento</option>
    
                                <option value="al">Alessandria</option>
                                
                                <option value="vb">Verbania</option>
                                <option value="vc">Vercelli</option>
                                <option value="vr">Verona</option>
                                <option value="vv">Vibo Valentia</option>
                                <option value="vi">Vicenza</option>
                                <option value="vt">Viterbo</option>
    
                                </select> </span></span></span></td>
                            </tr>
                            <tr>
                                <td height="35"><span><span>Telefono:</span></span></td>
                                <td height="35"><span><span><input style="BORDER-BOTTOM: 1px solid; BORDER-LEFT: 1px solid; FONT-FAMILY: Verdana,tahoma,Arial; BACKGROUND: rgb(255,255,255) 0% 50%; FONT-SIZE: 10px; BORDER-TOP: 1px solid; BORDER-RIGHT: 1px solid; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial" id="telephone" maxlength="40" size="22" name="telephone"/> </span></span></td>
                            </tr>
                            <tr>
    
                                <td height="148" colspan="2">
                                
    
    Autorizzo al trattamento dei dati personali secondo il Disposto di Legge 196/2003 per essere contattato e ricevere le informazioni da me richieste con la compilazione di questo modulo. 
    
                                
    
                                Attenzione: 
    
                                Per acconsentire che la nostra azienda possa ricontattarti &egrave; necessario confermare nella seguente casella. </p>
                                </td>
    
                            </tr>
                            <tr>
                                <td height="25"></td>
                                <td height="25"><input checked="checked" type="checkbox" name="trattamento_dati" value="trattamento_dati"/> <span>Consenso al trattamento dei dati</span></td>
                            </tr>
                            <tr>
                                <td height="69">Note:</td>
    
                                <td height="69"><span><span><textarea style="BORDER-BOTTOM: 1px solid; BORDER-LEFT: 1px solid; FONT-FAMILY: Verdana,tahoma,Arial; BACKGROUND: rgb(255,255,255) 0% 50%; FONT-SIZE: 10px; BORDER-TOP: 1px solid; BORDER-RIGHT: 1px solid; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial" id="comments" rows="3" cols="50" name="comments"></textarea> </span></span></td>
                            </tr>
                            <tr>
                                <td height="25"></td>
                                <td height="25"></td>
                            </tr>
                            <tr>
                                <td height="25" colspan="2" align="center"><span><input class="button" tabindex="6" type="submit" value="Clicca per inviare la richiesta"/> </span></td>
    
                            </tr>
                        </tbody>
                    </table>
                </form>
    e questo è lo script che mi hano dato
    codice:
    <?php if(isset($_POST['email'])) {           
    // EDIT THE 2 LINES BELOW AS REQUIRED     
    $email_to = "daimoncomunication@gmail.com";     
    $email_subject = "INFORMAZIONI GENERALI";                 
    function died($error) {         
    // your error code can go here         
    
    echo "Siamo dispiaciuti, ma ci sono errori nel form inviato. ";         
    echo "questi errori appaiono qui sotto.
    
    ";         
    echo $error."
    
    ";         
    echo "Per favore Torni indietro e Corregga gli Errori.
    
    ";         
    die();     }           
    
    $provincia = $_POST['provincia']; 
    
    // validation expected data exists     
    if(!isset($_POST['first_name']) || !isset($_POST['last_name']) || !isset($_POST['email']) || !isset($_POST['telephone']) || !isset($_POST['comments'])) 
    {         
    died('Siamo dispiaciuti, ma pare che siano roblemi con il form da lei compilato.');            
    }           
    $first_name = $_POST['first_name']; 
    // required     
    $last_name = $_POST['last_name']; 
    // required     
    $email_from = $_POST['email']; 
    // required     
    $telephone = $_POST['telephone']; 
    // not required     
    $comments = $_POST['comments']; 
    // required           
    $error_message = "";     
    $email_exp = "^[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$";   
    
    if(!eregi($email_exp,$email_from)) 
    {     
    	$error_message .= 'La Mail da lei compilata non è corretta.
    ';   
    }     
    $string_exp = "^[a-z .'-]+$";   
    if(!eregi($string_exp,$first_name)) 
    {     
    $error_message .= 'Il Nome deve apparire.
    ';   
    }   
    if(!eregi($string_exp,$last_name)) 
    {     
    $error_message .= 'Il Cognome deve apparire.
    ';   
    }   
    if(strlen($comments) < 2) 
    {     
    $error_message .= 'I Commenti da lei inseriti non solo validi.
    ';   
    }   
    if(strlen($error_message) > 0) 
    {     died($error_message);   
    }     
    $email_message = "Form details below.\n\n";           
    function clean_string($string) 
    {       
    $bad = array("content-type","bcc:","to:","cc:","href");       
    return str_replace($bad,"",$string);     
    }           
    $email_message .= "First Name: ".clean_string($first_name)."\n";     
    $email_message .= "Last Name: ".clean_string($last_name)."\n";     
    $email_message .= "Email: ".clean_string($email_from)."\n";     
    $email_message .= "Telephone: ".clean_string($telephone)."\n";     
    $email_message .= "Provincia: ".clean_string($provincia)."\n";     
    $email_message .= "Comments: ".clean_string($comments)."\n";             
    // create email headers 
    $headers = 'From: '.$email_from."\r\n". 'Reply-To: '.$email_from."\r\n" . 'X-Mailer: PHP/' . phpversion(); @mail($email_to, $email_subject, $email_message, $headers);   ?>   
       
    Thank you for contacting us. We will be in touch with you very soon.   <? } ?>
    Mi dice che la mail è stata inviata ma non arriva
    qualcuno sa aiutarmi??
    scusate la lunghezza del messaggio ma sono novellino di programmazione

    grazie
    Carlo

  2. #2
    Da dove stai eseguendo lo script?
    In locale sul web server del tuo pc, o su di un server in hosting?

  3. #3
    Da un hostin.. comunque ho risolto modificando in questo modo il codice
    codice:
    <?php
    if(isset($_POST['email'])) {
         
        // EDIT THE 2 LINES BELOW AS REQUIRED
        $email_to = "#@gmail.com";
        $email_subject = "INFORMAZIONI GENERALI";
         
         
        function died($error) {
            // your error code can go here
            echo "Siamo spiacenti, ma sono stati trovati degli errori nel form da lei compilato. ";
            echo "These errors appear below.
    
    ";
            echo $error."
    
    ";
            echo "Please go back and fix these errors.
    
    ";
            die();
        }
         
        // validation expected data exists
        if(!isset($_POST['first_name']) ||
            !isset($_POST['last_name']) ||
            !isset($_POST['email']) ||
            !isset($_POST['telephone']) ||
            !isset($_POST['comments'])) {
            died('We are sorry, but there appears to be a problem with the form you submitted.');      
        }
         
        $first_name = $_POST['first_name']; // required
        $last_name = $_POST['last_name']; // required
        $email_from = $_POST['email']; // required
        $telephone = $_POST['telephone']; // not required
        $provincia = $_POST['provincia']; // not required	
        $comments = $_POST['comments']; // required
         
        $error_message = "";
        $email_exp = "^[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$";
      if(!eregi($email_exp,$email_from)) {
        $error_message .= 'The Email Address you entered does not appear to be valid.
    ';
      }
        $string_exp = "^[a-z .'-]+$";
      if(!eregi($string_exp,$first_name)) {
        $error_message .= 'The First Name you entered does not appear to be valid.
    ';
      }
      if(!eregi($string_exp,$last_name)) {
        $error_message .= 'The Last Name you entered does not appear to be valid.
    ';
      }
      if(strlen($comments) < 2) {
        $error_message .= 'The Comments you entered do not appear to be valid.
    ';
      }
      if(strlen($error_message) > 0) {
        died($error_message);
      }
        $email_message = "Form details below.\n\n";
         
        function clean_string($string) {
          $bad = array("content-type","bcc:","to:","cc:","href");
          return str_replace($bad,"",$string);
        }
         
        $email_message .= "First Name: ".clean_string($first_name)."\n";
        $email_message .= "Last Name: ".clean_string($last_name)."\n";
        $email_message .= "Email: ".clean_string($email_from)."\n";
        $email_message .= "Telephone: ".clean_string($telephone)."\n";
        $email_message .= "Provincia: ".clean_string($provincia)."\n";
        $email_message .= "Comments: ".clean_string($comments)."\n";
         
         
    // create email headers
    $headers = 'From: '.$email_from."\r\n".
    'Reply-To: '.$email_from."\r\n" .
    'X-Mailer: PHP/' . phpversion();
    @mail($email_to, $email_subject, $email_message, $headers); 
    ?>
     
    
     
    Thank you for contacting us. We will be in touch with you very soon.
     
    <?
    }
    ?>
    Ora Funziona

    Ho letto un pò in giro per il forum ho provatio a cambiare qualcosa e funziona
    grazie per il supporto e scusate l'apertura del post

    Saluti
    Carlo

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