Visualizzazione dei risultati da 1 a 2 su 2

Discussione: aiuto urgente

  1. #1

    aiuto urgente

    Non riesco ad allegare un file in attachment ad un form.

    Dove sta' l'errore?

    qui sotto allego pagina.

    <html>

    <head>
    <title></title>

    <?
    #FUNZIONE VISUALIZZA FORM
    function print_form($company, $contact, $email, $tel, $address, $brazil, $europe, $uk, $usa, $model, $serial, $spare, $visit, $tele, $phone, $other, $message, $citta, $upfile) {
    ?>


    <table width="600" border="0" cellspacing="0" cellpadding="0">
    <span class="titolo-sez">Enquiry</span>

    <tr>
    <td valign="top" align="center">
    <form name="form" method="post" action="service.php" enctype="multipart/form-data">
    <input type="hidden" name="subject" value="Messaggio automatico">
    <table width="600" border="0" cellspacing="3" cellpadding="0" align="center">
    <tr>
    <td colspan="2">Customer</td>
    </tr>
    <tr>
    <td colspan="2" bgcolor="#000000" height="1">[img]images/t.gif[/img]</td>
    </tr>
    <tr>
    <td align="right"><FONT COLOR="#FFBA38">* </font>Company</td>
    <td align="left"><input type="text" name="company" value="<?php print $company ?>" size=15 class="dim"></td>
    </tr>
    <tr>
    <td align="right"><FONT COLOR="#FFBA38">* </font>Contact name</td>
    <td align="left"><input type="text" name="contact" value="<?php print $contact ?>" size=15 maxlength=20 class="dim"></td>
    </tr>
    <tr>
    <td align="right"><FONT COLOR="#FFBA38">* </font>Email</td>
    <td align="left"><input type="text" name="email" value="<?php print $email ?>" size=15 class="dim"></td>
    </tr>
    <tr>
    <td align="right">Phone</td>
    <td align="left"><input type="text" name="tel" value="<?php print $tel ?>" size=15 class="dim"></td>
    </tr>

    <tr>
    <td colspan="2">Plant</td>
    </tr>
    <tr>
    <td colspan="2" bgcolor="#000000" height="1">[img]images/t.gif[/img]</td>
    </tr>

    <tr>
    <td align="right">Address</td>
    <td align="left"><input type="text" name="address" value="<?php print $address ?>" size=15 class="dim"></td>
    </tr>
    <tr>
    <td align="right">City</td>
    <td align="left"><input type="text" name="citta" value="<?php print $citta ?>" size=15 class="dim"></td>
    </tr>
    <tr>
    <td align="right" valign="top">Brazil</td>
    <td align="left" colspan="2" valign="top"><INPUT TYPE="RADIO" VALUE="brazil" CHECKED NAME="radio_buttons"></td>
    </tr>
    <tr>
    <td align="right" valign="top">Continental Europe</td>
    <td align="left" colspan="2" valign="top"><INPUT TYPE="RADIO" VALUE="europe" CHECKED NAME="radio_buttons"></td>
    </tr>
    <tr>
    <td align="right" valign="top">United Kingdom</td>
    <td align="left" colspan="2" valign="top"><INPUT TYPE="RADIO" VALUE="uk" CHECKED NAME="radio_buttons"></td>
    </tr>
    <tr>
    <td align="right" valign="top">USA</td>
    <td align="left" colspan="2" valign="top"><INPUT TYPE="RADIO" VALUE="usa" CHECKED NAME="radio_buttons"></td>
    </tr>

    <tr>
    <td colspan="2">Machine</td>
    </tr>
    <tr>
    <td colspan="2" bgcolor="#000000" height="1">[img]images/t.gif[/img]</td>
    </tr>


    <tr>
    <td align="right">Model</td>
    <td align="left"><input type="text" name="model" value="<?php print $model ?>" size=15 class="dim"></td>
    </tr>

    <tr>
    <td align="right">Serial number</td>
    <td align="left"><input type="text" name="serial" value="<?php print $serial ?>" size=15 class="dim"></td>
    </tr>

    <tr>
    <td colspan="2">Required assistance</td>
    </tr>
    <tr>
    <td colspan="2" bgcolor="#000000" height="1">[img]images/t.gif[/img]</td>
    </tr>

    <tr>
    <td align="right" valign="top">Spare parts</td>
    <td align="left" colspan="2" valign="top"><input type="checkbox" name="spare" value="<?php print $spare ?> x"></td>
    </tr>
    <tr>
    <td align="right" valign="top">Visit by service engineer</td>
    <td align="left" colspan="2" valign="top"><input type="checkbox" name="visit" value="<?php print $visit ?> x"></td>
    </tr>
    <tr>
    <td align="right" valign="top">Tele-assistance (only machines with PC anywhere software - working hours 8/12 - 13/17)</td>
    <td align="left" colspan="2" valign="top"><input type="checkbox" name="tele" value="<?php print $tele ?> x"></td>
    </tr>
    <tr>
    <td align="right" valign="top">Phone assistance (please call +39.0362.542252 - working hours 8/12 - 13/17)</td>
    <td align="left" colspan="2" valign="top"><input type="checkbox" name="phone" value="<?php print $phone ?> x"></td>
    </tr>
    <tr>
    <td align="right" valign="top">Other</td>
    <td align="left" colspan="2" valign="top"><input type="checkbox" name="other" value="<?php print $other ?> x"></td>
    </tr>
    <tr>
    <td colspan="4">
    <?
    print("


    ATTACHMENT FILE <input class=fi type=\"file\" size=40 name=\"upfile\">

    <input type=\"hidden\" name=\"MAX_FILE_SIZE\" value=\"$max_size\">");
    ?>
    </td>
    </tr>
    <tr>
    <td align="right"></td>
    <td align="left"></td>
    </tr>
    <tr>
    <td valign="top" colspan="2">

    <table border="0" cellpadding="0" cellspacing="0" width="100%">
    <tr>
    <td valign="top"><div align="right">Details/Message
    </div></td>
    <td><textarea name="message" rows="10" cols="50" class="dim4"><?php print $message ?></textarea></td>
    </tr>
    </table>

    </td>
    </tr>
    <tr>
    <td colspan="2" bgcolor="#000000" height="1">[img]images/t.gif[/img]</td>
    </tr>
    <tr>
    <td colspan="2">Sipro Service Center closer to your plant will contact you A.S.A.P.</td>
    </tr>


    </table>

    <table width="400" border="0" cellspacing="0" cellpadding="0" align="center">
    <tr>
    <td align="center">
    The fields with the asterisk (<FONT COLOR="#FFBA38">*</font>) are request

    </td>
    </tr>
    <tr>
    <td align="center">
    <input type="Hidden" name="ope" value="CNT"><input type="submit" name="submit" value="Send"><input type="reset" name="Submit2" value="Delete"></td>
    </tr>
    </table>
    </form>
    </td>
    </tr>
    </table>


    <?
    }
    function spedisci_mail($to, $subject, $body, $from, $company, $contact, $email, $tel, $address, $brazil, $europe, $uk, $usa, $model, $serial, $spare, $visit, $tele, $phone, $other, $message, $citta, $upfile){
    $chked=0;
    if ($upfile == "none" || $upfile_size==0) $chked=1;
    if (checkfileatt($upfile_name,$upfile_size)!="No file attached") $chked=1;

    if($chked==0) {
    copy($upfile, $upfile_name);
    $fileatt=$upfile_name;
    $fileatt_type=$upfile_type;
    $fileatt_name=$upfile_name;
    $file = fopen($fileatt,'rb');
    $data = fread($file,filesize($fileatt));
    fclose($file);
    }


    //if($usa <> 0 ):
    //$to= "info@siprosrl.com; siproinc@att.net";
    $to= "info@emcd.it";
    //else:
    // $to= "info@emcd.it; siproinc@att.net";
    //endif;
    $semi_rand = md5(time());
    $mime_boundary = "==Multipart_Boundary_x{$semi_rand}x";

    $headers = "From: SitowebSIPROSRL <info@siprosrl.com>";
    $headers .= "\nMIME-Version: 1.0\n" . "Content-Type: multipart/mixed;\n" . " boundary=\"{$mime_boundary}\"";
    $body .= "Il seguente utente ha richiesto delle informazioni:\n\n";
    $body .= "


    Company: $company

    Contact name: $contact

    Email: $email

    Phone: $tel

    Address: $address

    City: $citta

    Country: $radio_buttons

    Model: $model

    Serial number: $serial

    Spare parts: $spare

    Visit by service engineer: visit

    Tele-assistance: $tele

    Phone assistance: $phone

    Other: $other

    Messaggio: $message
    ";
    $email_message = "This is a multi-part message in MIME format.\n\n" . "--{$mime_boundary}\n" . "Content-Type:text/html; charset=\"iso-8859-1\"\n" . "Content-Transfer-Encoding: 7bit\n\n" . $body . "\n\n";

    $subject="Form > Sezione Service siprosrl.com";

    $data = chunk_split(base64_encode($data));
    $email_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";
    $sending_ok = @mail($to, $subject, $email_message, $headers);

    if($chked==0) unlink($upfile_name);
    }

    function controllomail($email) {
    $ret = 0;
    if (eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@([0-9a-z][0-9a-z-]*[0-9a-z]\.)+[a-z]{2}[mtgvu]?$", $email, $check)) {
    if (!(getmxrr(substr(strstr($check[0], '@'), 1), $validate_email_temp))) {
    $ret = 1;
    };
    } else {
    $ret = 2;
    };
    return $ret;
    };

    function checkfileatt($upfile,$fsize){
    global $max_size;
    global $banned_ext;
    $err="No file attached";
    //Checking file type in or out of banned file extensions list
    $pos1=strrchr($upfile,".");
    $ftype=str_replace(".","",$pos1);
    $blist=explode("|",$banned_ext);
    for($i=0;$i<sizeof($blist)-1;$i++){
    if($ftype==$blist[$i]) $err="ERROR: Your file extension (*.$ftype) is not be accepted.";
    }
    //Check file size
    if(round($fsize/1024)>$max_size) $err="ERROR: Your file size (" .round($fsize/1024) ." Kb) is too large. We only accept $max_size Kb.";
    //Return the value
    return $err;
    }

    #FUNZIONE PRINCIPALE------------------------------------------------------------------------------------------------->
    switch ($ope) {
    case "CNT":

    if (check_form($email, $company, $contact)==1):
    confirm_form($company, $contact, $email, $tel, $address, $brazil, $europe, $uk, $usa, $model, $serial, $spare, $visit, $tele, $phone, $other, $message, $citta, $upfile, $upfile_name);
    spedisci_mail($to, $subject, $body, $from, $company, $contact, $email, $tel, $address, $brazil, $europe, $uk, $usa, $model, $serial, $spare, $visit, $tele, $phone, $other, $message, $citta, $upfile);
    else:
    echo ("

    ");
    print_form($company, $contact, $email, $tel, $address, $brazil, $europe, $uk, $usa, $model, $serial, $spare, $visit, $tele, $phone, $other, $message, $citta, $upfile, $upfile_name);
    endif;
    break;
    default:
    print_form($company, $contact, $email, $tel, $address, $brazil, $europe, $uk, $usa, $model, $serial, $spare, $visit, $tele, $phone, $other, $message, $citta, $upfile, $upfile_name);
    break;
    }
    ?>

  2. #2
    Addio Aldo, amico mio... [03/12/70 - 16/08/03]

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.