Visualizzazione dei risultati da 1 a 10 su 44

Visualizzazione discussione

  1. #3
    Utente di HTML.it
    Registrato dal
    Apr 2011
    Messaggi
    16
    O.k questo è il form.php

    Codice PHP:
        <form action="contatti.php" method="post">
          <table width="460" border="0" cellpadding="5" cellspacing="0">
            <tr>
              <td width="230" align="left" valign="middle"><p class="contactform">Nome e Cognome: *
                  <span style="color:#F00"><?php echo $_SESSION['nameerror'?></span><br />
                  <input name="name" type="text" id="name" value="<?php echo $_SESSION['name'?>" maxlength="60"/>
                </p></td>
              <td width="230" align="left" valign="middle"><p class="contactform">Email: *
                  <span style="color:#F00"><?php echo $_SESSION['emailerror'?></span><br />
                  <input name="email" type="text" id="email" value="<?php echo $_SESSION['email'?>" maxlength="100" />
                </p></td>
            </tr>
            <tr>
              <td align="left" valign="middle"><p class="contactform">Telefono:<br />
                  <input name="tel" type="text" id="tel" value="<?php echo $_SESSION['tel'?>" maxlength="20" />
                </p></td>
              <td align="left" valign="middle"><p class="contactform">Contattami:<br />
                <label>
                  <input border="0" type="radio" name="callback" value="Yes" id="callback_0" />
                  Yes</label>
                <label>
                  <input name="callback" type="radio" id="callback_1" value="No" checked="checked" border="0" />
                  No</label></p></td>
            </tr>
            <tr>
              <td colspan="2" align="left" valign="middle"><p class="contactform">Oggetto: *
         <span style="color:#F00"><?php echo $_SESSION['subjecterror'?></span><br />
                  <input name="subject" type="text" id="subject" value="<?php echo $_SESSION['subject'?>" maxlength="150"/>
                </p></td>
            </tr>
            <tr>
              <td colspan="2" align="left" valign="middle"><p class="contactform">Messaggio: *
                  <span style="color:#F00"><?php echo $_SESSION['messageerror'?></span><br />
                  <textarea name="message" cols="40" rows="10" id="message"><?php echo $_SESSION['message'?></textarea>
                </p></td>
            </tr>
            <tr>
              <td colspan="2" align="left" valign="middle"><p class="contactform">Anti Spam: *<br />
                  Sei umano?
                  <select name="humancheck" id="humancheck">
                    <option value="---">---</option>
                    <option value="no">No</option>
                    <option value="yes">Si</option>
                  </select>
                  <span style="color:#F00"><?php echo $_SESSION['humanerror'?></span></p>
    <p class="contactform">Privacy: *<br />
        <span class="Stile1"><a href="../privacy.pdf" target="_blank">Informativa sul trattamento dei dati personali</a> D.lgs. n. 196/2003</span><br />
                    <input type="checkbox" name="privacycheck" value="privacycheck" /> Acconsento
                <span style="color:#F00"><?php echo $_SESSION['privacyerror'?></span></p>        </tr>
            <tr>
              <td colspan="2" align="left" valign="middle"><input class="btn" type="submit" name="button" id="button" value="Invia" />
                <span style="color:#F00"><?php echo $_SESSION['senderror'?></span><br /></td>
            </tr>
          </table>
        </form>
    questo è il controllo contatti.php

    Codice PHP:
    <?php
    //Includes user settings
    include('config.php');
    session_start();
    $name   =  $_POST['name'];
    $email   =  $_POST['email'];
    $tel   =  $_POST['tel'];
    $human   =  $_POST['humancheck'];
    $privacycheck   =  $_POST['privacycheck'];
    $message  =  $_POST['message'];
    $callback  =  $_POST['callback'];
    $subject  =  $_POST['subject'];
    $ip   $_SERVER['REMOTE_ADDR'];
    $error   =  false;
    //Reset error messages
    $_SESSION['emailerror']  =  "";
    $_SESSION['nameerror']   =  "";
    $_SESSION['subjecterror']  =  "";
    $_SESSION['messageerror']  =  "";
    $_SESSION['humanerror']  = "";
    $_SESSION['privacyerror']  = "";
    $_SESSION['senderror']  = "";
    //Validation Session Variables
    $_SESSION['message']   =  $message;
    $_SESSION['tel']    =  $tel;
    $_SESSION['name']    =  $name;
    $_SESSION['email']    =  $email;
    $_SESSION['subject']   =  $subject;
    $_SESSION['privacycheck']   =  $privacycheck;
    //Validation
    if($name == ""){
     
     
    $_SESSION['nameerror'] = "Obbligatorio";
     
    $error true;
     
    }
    if(!
    eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$"$email)) {
     
     
    $_SESSION['emailerror'] = "E-mail non valida";
      
    $error true;
     
    }
    if(
    $email == ""){
     
     
    $_SESSION['emailerror'] = "Obbligatorio";
     
    $error true;
     
    }
    if(
    $subject == ""){
     
     
    $_SESSION['subjecterror'] = "Obbligatorio";
     
    $error true;
     
    }
    if(
    $message == ""){
     
     
    $_SESSION['messageerror'] = "Obbligatorio";
     
    $error true;
     
    }
    if(
    $privacycheck == ""){
     
     
    $_SESSION['privacyerror'] = "Obbligatoria l'accettazione.";
     
    $error true;
     
    }
    if(
    $human != "yes"){
     
     
    $error true;
     
    $_SESSION['humanerror'] = "Prego, selezionare Si.";
     
    }
    if(
    $error == true) {
     
     
    $_SESSION['senderror'] = "Campi errati o mancanti";
     
    header("Location: $contactpage");
     exit;
     
    } else {
     
    $to   $youremail;
    $sbj   "Messaggio dal sito";
    $msg   "
    <html>
    <head>
    <style type='text/css'>
    body{
     font-family:'Lucida Grande', Arial;
     color:#333;
     font-size:15px;
    }
    </style>
    </head>
    <body>
    <img src='"
    ."$logo"."' width='255' height='124' alt='Contatti' />
    <table width='600' border='0' cellspacing='0' cellpadding='5'>
      <tr>
        <td width='121' align='left' valign='baseline'><strong>Nome:</strong></td>
        <td width='459'>
    $name</td>
      </tr>
      <tr>
        <td align='left' valign='baseline'><strong>Email:</strong></td>
        <td>
    $email</td>
      </tr>
      <tr>
        <td align='left' valign='baseline'><strong>IP:</strong></td>
        <td>
    $ip</td>
      </tr>
      <tr>
        <td align='left' valign='baseline'><strong>Telefono:</strong></td>
        <td>
    $tel</td>
      </tr>
      <tr>
        <td align='left' valign='baseline'><strong>Contattami:</strong></td>
        <td>
    $callback</td>
      </tr>
      <tr>
        <td align='left' valign='baseline'><strong>Oggetto:</strong></td>
        <td>
    $subject</td>
      </tr>
      <tr>
        <td align='left' valign='baseline'><strong>Messaggio:</strong></td>
        <td>
    $message</td>
      </tr>
       <tr>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
      </tr>
        <tr>
        <td>&nbsp;</td>
        <td><small>Inviato da: </td>
      </tr>
    </table>
    </body>
    </html>
    "
    ;
    $from    $email;
    $headers  'MIME-Version: 1.0' "\r\n";
    $headers .= 'Content-type: text/html; charset=iso-8859-1' "\r\n";
    $headers  .= "From: $from";

    mail($to,$sbj,$msg,$headers); //Send to you.
    //END OF EMAIL TO ME
    //START EMAIL CONFIRMATION
    $toClient   $email;
    $msgClient   "
    <html>
    <head>
    <style type='text/css'>
    body{
     font-family:'Lucida Grande', Arial;
     color:#333;
     font-size:15px;
    }
    </style>
    </head>
    <body>
    <img src='"
    ."$logo"."' width='255' height='124' alt='contatti' />
    <table width='600' border='0' cellspacing='0' cellpadding='5'>
      <tr>
        <td width='117' align='right' valign='baseline'><strong>Grazie,</strong></td>
        <td width='463'>
    $name</td>
      </tr>
       <tr>
        <td>&nbsp;</td>
        <td>Abbiamo ricevuto il Vostro messaggio e Vi risponderemo al più presto possibile.</td>
      </tr>
        <tr>
        <td>&nbsp;</td>
      </tr>
    </table>
    </body>
    </html>
    "
    ;
    $fromClient   $email;
    $sbjClient   "Grazie, $name - $yourwebsite";
    $headersClient  'MIME-Version: 1.0' "\r\n";
    $headersClient .= 'Content-type: text/html; charset=iso-8859-1' "\r\n";
    $headersClient  .= "From: $fromClient";
    mail($toClient,$sbjClient,$msgClient,$headersClient); //Send to Client.
    //END EMAIL CONFIRMATION
    //Reset error messages
    $_SESSION['emailerror']  =  "";
    $_SESSION['nameerror']   =  "";
    $_SESSION['subjecterror']  =  "";
    $_SESSION['messageerror']  =  "";
    $_SESSION['humanerror']  = "";
    $_SESSION['privacyerror']  = "";
    $_SESSION['senderror']  = "";
    //Reset Validation Session Variables
    $_SESSION['message']   =  "";
    $_SESSION['tel']    =  "";
    $_SESSION['name']    =  "";
    $_SESSION['email']    =  "";
    $_SESSION['subject']   =  "";
    session_destroy();
    header("Location: $graziepage");
    exit;
    }
    ?>
    e questo è il config.php

    Codice PHP:
    <?php
    //Your email address e.g. "you@here.com"
    $youremail  =  "" ;

    //Your website e.g. "website.com"
    $yourwebsite "" ;

    //Path to your logo e.g. "http://www.yoursite.com/images/logo.jpg"
    //(Recommended size 255 x 124px)
    $logo   ""  ;

    //Thankyou page address e.g. "thankyou.php"
    $graziepage "grazie.php" ;
    //Contact form page e.g. "../form.php"
    $contactpage  "form.php"  ;

    //Return to home address after visiting the thankyou page e.g. "../index.php"
    $returnhome  =  "../index.html" ;
    ?>
    Grazie
    Ultima modifica di lucyanne; 29-12-2014 a 17:58

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.