Pagina 1 di 2 1 2 ultimoultimo
Visualizzazione dei risultati da 1 a 10 su 11
  1. #1

    Form Mail Semplicissimo piccola modifica che non so fare

    Salve ho trovato questo form mail semplicissimo e funziona benissimo

    ho eliminato i campi che non mi servivano e funziona ancora ( miracolosamente! )

    solo una cosa non so fare ma credo molto semplice

    il Subjet non deve essere scritto dall utente che compila il form
    ma deve essere predefinito e chiaramente non visibile dal form

    quando ti arriva una mail deve arrivare

    Subjet : Richiesta Form www.miosito.com


    potreste modificarlo? credo che e' solo una riga qualcosa del genere
    cosi inizio anche a imparare un po

    grazie mille


    <?php
    /**
    * Contact form with file attachment
    * Release Date: April 24th 2008
    * Author: Elle Meredith <http://designbyelle.com.au/>
    *
    * Resources used to create this script
    * phMailer <http://www.phphq.net?script=phMailer> by Scott L. <scott@phphq.net>
    * an article on Sitepoint by Kevin Yank, (13 Feb 2003) Accessed on April 24, 2008
    * "Advanced email in PHP" <http://www.sitepoint.com/article/advanced-email-php>
    * and "PHP: Sending Email (Text/HTML/Attachments)"
    * <http://www.webcheatsheet.com/php/sen...attachment.php>
    *
    * This script is free software; you can redistribute it and/or modify
    * it under the terms of the GNU General Public License as published by
    * the Free Software Foundation; either version 2 of the License, or
    * (at your option) any later version.
    *
    * This script is distributed in the hope that it will be useful,
    * but WITHOUT ANY WARRANTY; without even the implied warranty of
    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
    * GNU General Public License for more details.
    * http://www.gnu.org/licenses/gpl.txt
    *
    */



    // prints form
    function print_form(){
    ?>
    <style type="text/css">
    <!--
    .Stile1 {color: #FF0000}
    -->
    </style>

    <p class="Stile1"><span class="required">*</span> Campi Obbligatori</p>
    <form method="post" action="<?php echo $PHP_SELF;?>" id="uploadform" enctype="multipart/form-data">



    <label for="namefrom"></label></p>

    <table width="314" border="0" cellpadding="3" cellspacing="3">
    <tr>
    <td><label for="label">Nome <span class="required Stile1">*</span></label></td>
    <td><input name="namefrom" id="namefrom" type="text" class="field" tabindex="1"/></td>
    </tr>
    <tr>
    <td>Cognome <span class="Stile1">*</span></td>
    <td><input name="company" id="company" type="text" class="field" tabindex="2"/></td>
    </tr>
    <tr>
    <td>Email <span class="required Stile1">*</span></td>
    <td><input name="emailfrom" id="emailfrom" type="text" class="field" tabindex="3"/></td>
    </tr>
    <tr>
    <td>Telefono</td>
    <td><input name="phone" id="phone" type="text" class="field" tabindex="4"/></td>
    </tr>
    <tr>
    <td>Subject <span class="required Stile1">*</span></td>
    <td><input name="subject" id="subject" type="text" class="field" tabindex="5"/></td>
    </tr>
    <tr>
    <td>Comments <span class="required Stile1">*</span></td>
    <td><textarea name="comments" id="comments" rows="7" cols="10" class="field" tabindex="6"></textarea></td>
    </tr>
    <tr>
    <td colspan="2"><div align="center">
    <input type="submit" name="submit" id="submit" value="Invia" tabindex="8"/>
    </div></td>
    </tr>
    </table>



    <label for="company"></label>
    <label for="emailfrom"></label>
    <label for="phone"></label>
    </p>


    <label for="subject"></label>
    </p>


    <label for="comments"></label>
    </p>


    <label for="attachment"></label>



    <input type="hidden" name="submitted" value="true" /></p>
    </form>
    <?php
    }

    // enquiry form validation

    function process_form() {
    // Read POST request params into global vars
    // FILL IN YOUR EMAIL
    $to = "info@cilentocomputer.com";
    $subject = trim($_POST['subject']);
    $namefrom = trim($_POST['namefrom']);
    $company = trim($_POST['company']);
    $phone = trim($_POST['phone']);
    $emailfrom = trim($_POST['emailfrom']);
    $comments = trim($_POST['comments']);


    // Thank you message
    $thanksmessage="Your email has been sent, we will respond shortly.";

    $errors = array(); //Initialize error array

    //checks for a name
    if (empty($_POST['namefrom']) ) {
    $errors[]='You forgot to enter your name';
    }

    //checks for an email
    if (empty($_POST['emailfrom']) ) {
    $errors[]='You forgot to enter your email';
    } else {

    if (!eregi ('^[[:alnum:]][a-z0-9_\.\-]*@[a-z0-9\.\-]+\.[a-z]{2,4}$', stripslashes(trim($_POST['emailfrom'])))) {
    $errors[]='Please enter a valid email address';
    } // if eregi
    } // if empty email

    //checks for a subject
    if (empty($_POST['subject']) ) {
    $errors[]='You forgot to enter a subject';
    }

    //checks for a message
    if (empty($_POST['comments']) ) {
    $errors[]='You forgot to enter your comments';
    }

    //checks attachment file
    // checks that we have a file
    if((!empty($_FILES["attachment"])) && ($_FILES['attachment']['error'] == 0)) {
    // basename -- Returns filename component of path
    $filename = basename($_FILES['attachment']['name']);
    $ext = substr($filename, strrpos($filename, '.') + 1);
    $filesize=$_FILES['attachment']['size'];
    $max_bytes=$max_file_size*1024;

    //Check if the file type uploaded is a valid file type.
    if (!in_array($ext, $allowtypes)) {
    $errors[]="Invalid extension for your file: ".$filename."";

    // check the size of each file
    } elseif($filesize > $max_bytes) {
    $errors[]= "Your file: ".$filename." is to big. Max file size is ".$max_file_size."kb.";
    }

    } // if !empty FILES

    if (empty($errors)) { //If everything is OK

    // send an email
    // Obtain file upload vars
    $fileatt = $_FILES['attachment']['tmp_name'];
    $fileatt_type = $_FILES['attachment']['type'];
    $fileatt_name = $_FILES['attachment']['name'];

    // Headers
    $headers = "From: $emailfrom";

    if (is_uploaded_file($fileatt)) {
    // Read the file to be attached ('rb' = read binary)
    $file = fopen($fileatt,'rb');
    $data = fread($file,filesize($fileatt));
    fclose($file);

    // create a boundary string. It must be unique
    $semi_rand = md5(time());
    $mime_boundary = "==Multipart_Boundary_x{$semi_rand}x";

    // Add the headers for a file attachment
    $headers .= "\nMIME-Version: 1.0\n" .
    "Content-Type: multipart/mixed;\n" .
    " boundary=\"{$mime_boundary}\"";

    // Add a multipart boundary above the plain message
    $message ="This is a multi-part message in MIME format.\n\n";
    $message.="--{$mime_boundary}\n";
    $message.="Content-Type: text/plain; charset=\"iso-8859-1\"\n";
    $message.="Content-Transfer-Encoding: 7bit\n\n";
    $message.="From: ".$namefrom."\n";
    $message.="Company: ".$company."\n";
    $message.="Phone: ".$phone."\n";
    $message.="Comments: ".$comments."\n\n";

    // Base64 encode the file data
    $data = chunk_split(base64_encode($data));

    // Add file attachment to the message
    $message .= "--{$mime_boundary}\n" .
    "Content-Type: {$fileatt_type};\n" .
    " name=\"{$fileatt_name}\"\n" .
    //"Content-Disposition: attachment;\n" .
    //" filename=\"{$fileatt_name}\"\n" .
    "Content-Transfer-Encoding: base64\n\n" .
    $data . "\n\n" .
    "--{$mime_boundary}--\n";
    }


    // Send the completed message
    if(!mail($to,$subject,$message,$headers)) {
    exit("Mail could not be sent. Sorry! An error has occurred, please report this to the website administrator.\n");
    } else {
    echo '<div id="formfeedback"><h3>Thank You!</h3>

    '. $thanksmessage .'</p></div>';
    print_form();
    } // end of if !mail

    } else { //report the errors
    echo '<div id="formfeedback"><h3>Error!</h3>

    The following error(s) has occurred:
    ';
    foreach ($errors as $msg) { //prints each error
    echo " - $msg
    \n";
    } // end of foreach
    echo '</p>

    Please try again</p></div>';
    print_form();
    } //end of if(empty($errors))

    } // end of process_form()
    ?>

  2. #2
    Utente di HTML.it
    Registrato dal
    Jan 2009
    Messaggi
    777
    scusa non ho capito
    il subject deve arrivare dall'utente? è un indirizzo del sito dell'utente?
    se è cosi,allora quando ricevi il subject dopo il controllo empty
    scrivi
    Codice PHP:
    $subject="Richiesta Form $subjet"

  3. #3
    ciao grazie per la risposta

    il form online e questo

    http://www.bluemarinesrl.it/Form/

    il form arriva a me chiaramente ma come strutturato ora oggetto viene scritto dal utente che visita il sito

    io devo cancellare quel campo dal " form " e inserire una stringa che in automatico mi manda oggetto gia scritto

    se non erro ho fatto questa prova che hai scritto tu ma mi dava errore riga 46


    tu dici che devo modificare la tua stringa con questa?

    function process_form() {
    // Read POST request params into global vars
    // FILL IN YOUR EMAIL
    $to = "info@cilentocomputer.com";
    $subject = trim($_POST['subject']); <<<<<<<<<<<<<< qui ?
    $namefrom = trim($_POST['namefrom']);
    $company = trim($_POST['company']);
    $phone = trim($_POST['phone']);
    $emailfrom = trim($_POST['emailfrom']);
    $comments = trim($_POST['comments']);

  4. #4
    Utente di HTML.it
    Registrato dal
    Jan 2009
    Messaggi
    777
    scrivi cosi

    Codice PHP:
    $subject="Richiesta Form".$subjet
    la devi mettere subito dopo il controllo dell'empty
    Codice PHP:
    //checks for a message
    if (empty($_POST['comments']) ) {
    $errors[]='You forgot to enter your comments';


  5. #5
    grazie mielle funziona benissimo , chiaramente ho cancellato il campo subjet e il controllo

    ho provato una decina di form ma erano tutti complicati con 2000 opzioni questo e un unico file da includere in una pagina e va una bomba

    grazie ancora

  6. #6
    scusate riscrivo dinuovo

    ma il form non funziona, non me ne ero accorto perche' facevo prove veloci e non avevo aperto la mail

    sia originale sia modificato, grazie a amphioxus

    mi arriva solo Da chi.. e Subjet..

    citta', nome, cognome, ecc non arriva

    c'e' qualche errore nello script? voi che potete analizzarlo.. non vorrei mettermi a ricercare dato che era ottimo per le mie esigenze

    o al massimo se me ne segnalate qualcuno cosi semplice di 1 sola pagina

  7. #7
    Utente di HTML.it
    Registrato dal
    Jan 2009
    Messaggi
    777
    sostituisci
    $message.=
    con
    $message .=
    mettici lo spazio tra la e e ilpunto

  8. #8
    Utente di HTML.it
    Registrato dal
    Jan 2009
    Messaggi
    777
    Codice PHP:
    $message ="This is a multi-part message in MIME format.\n\n";
    $message .="--{$mime_boundary}\n";
    $message .="Content-Type: text/plain; charset=\"iso-8859-1\"\n";
    $message .="Content-Transfer-Encoding: 7bit\n\n";
    $message .="From: ".$namefrom."\n";
    $message .="Company: ".$company."\n";
    $message .="Phone: ".$phone."\n";
    $message .="Comments: ".$comments."\n\n"

  9. #9
    graize per l'aiuto come i precedenti ma niente arriva solo questo



    Da dagonblackheart@email.it
    A info@cilentocomputer.com
    Oggetto Richiesta Form www.bluemarinesrl.it << grazie alla tua modifica esce cosi

    i campi che vanno all'interno della mail non ci sono e tutto bianco

  10. #10
    Utente di HTML.it
    Registrato dal
    Jan 2009
    Messaggi
    777
    ma message l'hai cambiato come ti ho detto

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.