Page 3 of 3 FirstFirst 123
Results 21 to 25 of 25

Thread: mail form with upload file

  1. #21
    Join Date
    Jul 2006
    Location
    Antwerp, Belgium (Europe)
    Posts
    927
    Thanks
    121
    Thanked 2 Times in 2 Posts

    Default

    Code:
            <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
                "http://www.w3.org/TR/html4/strict.dtd">
    <head>
    
    <title>Ceci Casariego: contact gegevens</title>
    <meta name="Author" content="Fine arts, portraits and decoration by Ceci Casariego Mazereel">
    <meta name="DESCRIPTION" content="Ceci Casariego: portretten, ontwerp, design en interieur decoratie">
    <meta name="KEYWORDS" content="cecicasariego,casariegoart,Cecilia,Ceci,Chechu,Laura,Casariego,Mazereel,Bruno,Negrito,Argentina,Argentinie,schilderes,paintor,artist,artiste,pintora,kunstenares,portretkunst,portret,portrait,portretkunstenaar,portretkunstenares,directory,paintings,pinturas,kunst,art,arte,oil,oleo,olie,canvas,doek,tela,paper,papel,papier,ink,tinta,inkt,pastel,acrilico,acrilic,acriel,decoratie,decoration,decoracion,fresco,wallpainting,wood,board,muurschilderijen,interieur,interior,verfeffecten,trompe,loeil,portretten,portraits,retratos,realistic,realistisch,real,fotografisch,photographic,Belgium,Belgica,Belgie,Cambrinus,Damier,hotel,Plenso,Belstat,Outside,Travel,Bert,Lamaire,Unitron,Kwakkelnest,Neerplaats,Deltronic,Nocturnes,Piet,Lesage,Videoland,Poperinge,DHaene,Azart,Kaders,Bonnaffe,Alinia,Nudes,Flemish,Begijnhof,Diest,ExLibris,kunstacademie,kunstakademie,Euro,Region,Euroregion,Miss,verkiezing,election,naaktschilderijen,kunstschilder,portretkunst">
    <meta name="ROBOTS" content="NOARCHIVE">
    <meta name="REVISIT-AFTER" content="2 days">
    <meta name="Classification" content="Artist,decorator,portraitist">
    <meta name="language" content="English,Nederlands,Français">
    <meta name="doc-type" content="Public">
    <meta name="doc-class" content="Completed">
    <meta name="doc-rights" content="Copy Written Work">
    <meta name="resource-type" content="document">
    <meta name="generator" content="Developed by Bruno Mazereel">
    <meta name="distribution" content="Global">
    <meta name="rating" content="General">
    <meta name="copyright" content="Ceci and Bruno Casariego-Mazereel">
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <link rel="stylesheet" media="all" type="text/css" href="site.css">
    <meta http-equiv="imagetoolbar" content="no">
    <script src="links.js" type="text/javascript"></script>
    <link rel="shortcut icon" href="images/favicon.ico" type="image/x-icon">
    
    <style type="text/css">
    <!--
    div#container {
        margin:0 auto;
        background: #f2f4f7;
    }
    
    label {
        float: left;
        width: 140px;
        text-align: left;
        padding-top: 5px;
    }
    
    input, textarea {
        padding: 3px;
        margin: 3px;
        border: 1px solid #bac5d6;
        font: 10px Verdana, sans-serif;
        background: #fff;
    }
    input.fout, textarea.fout {
        border: 1px solid #FF0000;
    }
    
    label.fout {
        color: #FF0000;
    }
    -->
    </style>
    
    </head>
    
    <body>
    
    
        <div id="content">   
        <?php
        if(isset($errors)) {
            echo $errors;
        }
        ?>
    
    <script type="text/javascript">
    <!--
    var message="";
    ///////////////////////////////////
    function clickIE() {if (document.all) {(message);return false;}}
    function clickNS(e) {if 
    (document.layers||(document.getElementById&&!document.all)) {
    if (e.which==2||e.which==3) {(message);return false;}}}
    if (document.layers) 
    {document.captureEvents(Event.MOUSEDOWN);document.onmousedown=clickNS;}
    else{document.onmouseup=clickNS;document.oncontextmenu=clickIE;}
    
    document.oncontextmenu=new Function("return false")
    // --> 
    </script>
    
    <div id="header-main">
    <div id="headerNL">
    
    <h1>Ceci CASARIEGO</h1>
    <ul>
    <li class="nav"><a href="index.html">home</a></li>
    <li class="nav"><a href="portfolioNL.html">portfolio</a></li>
    <li class="nav"><a href="cvNL.html">curriculum</a></li>
    <li class="nav"><a href="newsNL.html">nieuws</a></li>
    <li class="nav"><a href="linksNL.html">links</a></li>
    <li class="nav"><a href="testNL.html">getuigenissen</a></li>
    <li class="hover">contact</li>
    </ul>
    
    </div>
    </div>
    
    <div id="body-main">
    <div id="body">
    
    <div id="left">
    <div style="padding-top:15px; padding-bottom:17px;"><input type="text" value=" True Artist LinkedIn Group" style="width:135px; border:1px solid #bbaaaa">
    <br>
    <a href="http://artists.cecicasariego.com" target="_blank"><img src="images/meer.gif" style="border:0px; padding-top:5px;"></a></div>
    <ul class="sub-link">
    <li><a href="copyNL.html">© copyright 2004-2008</a></li>
    <li class="noimg"><a href="contact.html">| EN |</a></li>
    </ul>
    
    <div id="event">
    <br>&nbsp;<br>
    <img src="images/sendarrow.gif">&nbsp; portret aanvragen: <a href="faqNL.html">veelgestelde vragen</a><br>
    <img src="images/sendarrow.gif">&nbsp; voor meer informatie: +32.(0)475.98.49.96
    </div>
    
    </div>
    
    <div id="right">
    <h2>Contact</h2>
    <p class="top-text">
    
    Heb je vragen of opmerkingen, laat het Ceci weten. Heb je vragen over wat belangrijk is bij een portretopdracht, 
    bekijk dan eerst de <a href="faqNL.html">veelgestelde vragen</a>. Je kan tot vijf foto's toevoegen.
    <br>&nbsp;<br>&nbsp;<br>
    
    
    <?php
    ############################################
    #  Filename   : contact.php                #
    #------------------------------------------#
    #  Written By : Thijs Ferket               #
    #  Website    : www.ferket.net             #
    #------------------------------------------#
    ############################################
    
    ini_set('display_errors', 1);
    error_reporting(E_ALL);
    
    ob_start();
    session_start();
    
    // Config Gedeelte
    $cfg['url'] = "http://www.cecicasariego.com";// Site waarnaar je terug gaat als je een bericht hebt achtergelaten
    $cfg['naam'] = "Ceci Casariego";                // Webmaster naam
    $cfg['email'] = "info@cecicasariego.com";        // Webmaster E-mail
    $cfg['spam'] = 10;                        // Anti Spam Tijd in Minuten ( Voer "0" om de Spam Beveiliging uit te zetten )
    $cfg['text'] = TRUE;                    // Bij Fout Text Rood maken ( TRUE voor aan, FALSE voor uit )
    $cfg['input'] = TRUE;                    // Bij Fout Border om Vakje Rood maken ( TRUE voor aan, FALSE voor uit )
    $cfg['HTML'] = TRUE;                    // Een HTML email ( TRUE voor aan, FALSE voor uit )
    $cfg['CAPTCHA'] = TRUE;                    // CAPTCHA ( TRUE voor aan, FALSE voor uit )
    
    
    // Hieronder niks meer veranderen
    // E-mail Checker / Validator
    function checkmail($email)
    {
        if(eregi("^[0-9a-z]([-_.]?[0-9a-z])*@[0-9a-z]([-.]?[0-9a-z])*\\.[a-z]{2,4}$", $email))
        {
            return TRUE;
        }
        return FALSE;
    }
    
    $formulier = TRUE;
    
    if(!isset($_COOKIE['formulier']))
    {
        if(isset($_POST['wis']) && ($_SERVER['REQUEST_METHOD'] == "POST"))
        {
            foreach($_POST as $key => $value)
            {
                unset($value);
            }
            header("Location: ".$_SERVER['PHP_SELF']."");
        }
            
        if(isset($_POST['verzenden']) && ($_SERVER['REQUEST_METHOD'] == "POST"))
        {
            $aFout = array();
            
            $naam = trim($_POST['naam']);
            $email = trim($_POST['email']);
            $onderwerp = trim($_POST['onderwerp']);
            $bericht = trim($_POST['bericht']);
            
            if($cfg['CAPTCHA'])
            {
                $code = $_POST['code'];
            }
                    
            if(empty($naam) || (strlen($naam) < 3) || eregi("[<>]", $naam) )
            {
                $aFout[] = "Er is geen naam ingevuld.";
                unset($naam);
                $fout['text']['naam'] = TRUE;
                $fout['input']['naam'] = TRUE;
            }
            if(empty($email))
            {
                $aFout[] = "Er is geen e-mail adres ingevuld.";
                unset($email);
                $fout['text']['email'] = TRUE;
                $fout['input']['email'] = TRUE;
            }
            elseif(checkmail($email) == 0)
            // Wanneer je PHP 5.2 > gebruikt
            //elseif(!filter_var($email, FILTER_VALIDATE_EMAIL)) 
            {
                $aFout[] = "Er is geen correct e-mail adres ingevuld.";
                unset($email);
                $fout['text']['email'] = TRUE;
                $fout['input']['email'] = TRUE;
            }
            if(empty($onderwerp))
            {
                $aFout[] = "Er is geen onderwerp ingevuld.";
                unset($onderwerp);
                $fout['text']['onderwerp'] = TRUE;
                $fout['input']['onderwerp'] = TRUE;
            }
            if(empty($bericht))
            {
                $aFout[] = "Er is geen bericht ingevuld.";
                unset($bericht);
                $fout['text']['bericht'] = TRUE;
                $fout['input']['bericht'] = TRUE;
            }
            if($cfg['CAPTCHA'])
            {
                if(strtoupper($code) != $_SESSION['captcha_code'])
                {
                    $aFout[] = "Er is geen correcte code ingevuld.";
                    $fout['text']['code'] = TRUE;
                    $fout['input']['code'] = TRUE;
                }
            }
            if(!$cfg['text'])
            {
                unset($fout['text']);
            }
            if(!$cfg['input'])
            {
                unset($fout['input']);
            }
            if(!empty( $aFout ))
            {
                $errors = '
                <div id="errors">
                <ul>';
                foreach($aFout as $sFout)
                {
                    $errors .= "    <li>".$sFout."</li>\n";
                }
                $errors .= "</ul>
                </div>";
            }
            else
            {
                $formulier = FALSE;
                
                
                if($cfg['HTML'])
                {
                    // Headers
                    $headers = "From: \"Contact Formulier\" <".$cfg['email'].">\r\n"; 
                    $headers .= "Reply-To: \"".$naam."\" <".$email.">\n";
                    $headers .= "Return-Path: Mail-Error <".$cfg['email'].">\n";
                    $headers .= "MIME-Version: 1.0\n";
                    $headers .= "Content-Transfer-Encoding: 8bit\n";
                    $headers .= "Content-type: text/html; charset=iso-8859-1\n";
                    
                    
                    $bericht = '

  2. #22
    Join Date
    Jul 2006
    Location
    Antwerp, Belgium (Europe)
    Posts
    927
    Thanks
    121
    Thanked 2 Times in 2 Posts

    Default

    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
                    <html>
                    <head>
                    </head>
                
                    <body>
                    <br />
                    <b>Naam:</b> '.$naam.'<br />
                    <b>Email:</b> <a href=\"mailto:'.$email.'\">'.$email.'</a><br />
                    <br />
                    <b>Bericht:</b><br />
                    '.$bericht.'
                    <br />
                    <br />
                    <br />
                    --------------------------------------------------------------------------<br />
                    <b>Datum:</b> '.date("d-m-Y @ H:i:s").'<br />
                    <b>IP:</b> <a href=\"http://sunny.nic.com/cgi-bin/whois?domain='.$_SERVER['REMOTE_ADDR'].'\">'.$_SERVER['REMOTE_ADDR'].'</a><br />
                    <b>Host:</b> '.gethostbyaddr($_SERVER['REMOTE_ADDR']).'<br />
                    </body>
                    </html>';
                }
                else 
                {
                    $bericht_wrap = wordwrap ($bericht, 40, "\n", 1);
                    // Headers
                    $headers = "From: \"Contact Formulier\" <".$cfg['email'].">\n"; 
                    $headers .= "MIME-Version: 1.0\n";
                    $headers .= "Content-type: text/plain; charset='iso-8859-1'\n"; 
                
                    // Bericht
                    $message = "Naam: ".$naam."        \n";
                    $message .= "E-mail: ".$email."     \n";
                    $message .= "Bericht:\n".$bericht_wrap."     \n ";
                    $message .= "               \n ";
                    $message .= "Datum: ".date("d-m-Y H:i:s")." \n";
                    $message .= "------------------------------------------------------- \n ";
                    $message .= "IP: ".$_SERVER['REMOTE_ADDR']."                    \n ";
                    $message .= "Host: ".gethostbyaddr($_SERVER['REMOTE_ADDR'])."                \n ";
                
                }
            
                if(mail($cfg['email'], "[Contact] ".$onderwerp, $bericht, $headers)) 
                {
                    if(isset($_POST['stuurkopie']))
                    {
                        $headers = "From: \"Contact Formulier\" <".$email.">\r\n"; 
                        $headers .= "Reply-To: \"".$naam."\" <".$email.">\n";
                        $headers .= "Return-Path: Mail-Error <".$email.">\n";
                        $headers .= "MIME-Version: 1.0\n";
                        $headers .= "Content-Transfer-Encoding: 8bit\n";
                        $headers .= "Content-type: text/html; charset=iso-8859-1\n";
                        
                        mail($email, "[Contact] ".$onderwerp, $bericht, $headers);
                    
                    }
                    
                    unset($naam, $email, $onderwerp, $bericht);
                    setcookie("formulier", 1, time() + ( $cfg['spam'] * 60 ) );
            
                    echo "
                    <p>
                    Uw bericht is succesvol verzonden, er word zo snel mogelijk gereageerd.<br />
                    <br />
                    Met vriendelijke groeten,<br />
                    <b>".$cfg['naam']."</b>
                    </p>
                    ";    
                }
                else
                {
                    echo "Er is een fout opgetreden bij het verzenden van de email";
                }
                header("refresh:3;url=".$cfg['url']."");
            }
        }
        if($formulier)
        {
        ?>
        <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
         "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
        
        <html xmlns="http://www.w3.org/1999/xhtml">
        <head>
            <link href="style.css" rel="stylesheet" type="text/css" />
            
            <title>Contact Formulier door Thijs</title>
            <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
            <meta http-equiv="Content-Language" content="nl" />
        </head>
        
        <body>
        <div id="container">   
        <?php
        if(isset($errors)) {
            echo $errors;
        }
        ?>
    
        
        <form method="post" action="<?php $_SERVER['PHP_SELF']; ?>">
            <p>
            <label <?php if(isset($fout['text']['naam'])) { echo 'class="fout"'; } ?>>Naam:</label>
            <input type="text" id="naam" name="naam" maxlength="30" <?php if(isset($fout['input']['naam'])) { echo 'class="fout"'; } ?> value="<?php if (!empty($naam)) { echo stripslashes($naam); } ?>" /><br />
            
            <label <?php if(isset($fout['text']['email'])) { echo 'class="fout"'; } ?>>Email:</label>
            <input type="text" id="email" name="email" maxlength="255" <?php if(isset($fout['input']['email'])) { echo 'class="fout"'; } ?> value="<?php if (!empty($email)) { echo stripslashes($email); } ?>" /><br />
            
            <label <?php if(isset($fout['text']['onderwerp'])) { echo 'class="fout"'; } ?>>Onderwerp:</label>
            <input type="text" id="onderwerp" name="onderwerp" maxlength="40" <?php if(isset($fout['input']['onderwerp'])) { echo 'class="fout'; } ?> value="<?php if (!empty($onderwerp)) { echo stripslashes($onderwerp); } ?>" /><br />
            
            <label <?php if(isset($fout['text']['bericht'])) { echo 'class="fout"'; } ?>>Bericht:</label>
            <textarea id="bericht" name="bericht" <?php if(isset($fout['input']['bericht'])) { echo 'class="fout"'; } ?> cols="30" rows="6"><?php if (!empty($bericht)) { echo stripslashes($bericht); } ?></textarea><br />
    
            <?php
            if($cfg['CAPTCHA'])
            {
            ?>
            <label></label>
            <img src="captcha.php" alt="" /><br />
            
            <label <?php if(isset($fout['text']['code'])) { echo 'class="fout"'; } ?>>Code:</label>
            <input type="text" id="code" name="code" maxlength="4" size="4" <?php if(isset($fout['input']['code'])) { echo 'class="captcha fout"'; } ?> /><br />
            <?php 
            }
            ?>
            <label for="stuurkopie">Stuur mij een kopie</label><input type="checkbox" id="stuurkopie" name="stuurkopie" value="1" /><br />
            
            <label></label>
            <input type="submit" id="verzenden" name="verzenden" value="verzenden" />
            <input type="submit" id="wis" name="wis" value="Wis velden" />
            </p>
        </form>
    
    </div>
    </div>
    </div>
            
    </body>   
    </html>
    
        <?php
        }
    }
    else 
    {
        echo "
        <p>
        U kunt maar eens in de ".$cfg['spam']." minuten een e-mail versturen!<br />
        U wordt nu automatisch doorgestuurd.
        </p>";
        header("refresh:3;url=".$cfg['url']."");
    }
    ?>

  3. #23
    Join Date
    Jul 2006
    Location
    Antwerp, Belgium (Europe)
    Posts
    927
    Thanks
    121
    Thanked 2 Times in 2 Posts

    Default

    Okay, now it is getting way too compicated, so let's start again.

    I have two codes, of which one gives me an error.

    This is the link where you can see the code at work:http://www.cecicasariego.com/testcontact2.php

    This is the error message:
    Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /customers/cecicasariego.com/cecicasariego.com/httpd.www/testcontact2.php:8) in /customers/cecicasariego.com/cecicasariego.com/httpd.www/testcontact2.php on line 145


    You can find the code of the script in the two post before this one. What causes the error ?

    Then my next step would be to mix that script with the one below, and then I have reached my goal. So bear with me just this one more, and then I have the perfect script !
    Last edited by chechu; 07-08-2008 at 08:15 AM.

  4. #24
    Join Date
    Jul 2006
    Location
    Antwerp, Belgium (Europe)
    Posts
    927
    Thanks
    121
    Thanked 2 Times in 2 Posts

    Default

    multiple upload form
    Code:
    <?php
        ini_set ('display_errors', 1);
        error_reporting (E_ALL);
        $title = 'Dynamic Multiple File Uploads';
        $msgs = array ();
        $errs = array ();
        /*
            Constanten voor exif_imagetype ()
            1      IMAGETYPE_GIF
            2     IMAGETYPE_JPEG
            3     IMAGETYPE_PNG
        */
        $allowed = array (IMAGETYPE_JPEG);
    
        function resize ($path, $dst_w) {
            list ($src_w, $src_h) = getimagesize ($path);
            if ($dst_w < $src_w) {
                $ratio = $dst_w / $src_w;
                $dst_h = ceil ($ratio * $src_h);
                $src = imagecreatefromjpeg ($path);
                $dst = imagecreatetruecolor ($dst_w, $dst_h);
                imagecopyresampled ($dst, $src, 0, 0, 0, 0, $dst_w, $dst_h, $src_w, $src_h);
                imagejpeg ($dst, $path, 80);
                imagedestroy ($src);
                imagedestroy ($dst);
            }
        }
        
        // business logic
        if ($_SERVER['REQUEST_METHOD'] == 'POST') {
            $n = count ($_FILES['userfile']['error']);
            for ($i = 0; $i < $n; $i++) {
                if (!$_FILES['userfile']['error'][$i]) {
                    $tmp = $_FILES['userfile']['tmp_name'][$i];
                    $name = $_FILES['userfile']['name'][$i];
                    $dir = 'images/';
                    if (!in_array (exif_imagetype ($tmp), $allowed)) {
                        array_push ($errs, 'Sorry, alleen JPG');
                    }
                    elseif ($_FILES['userfile']['size'][$i] > 50000) {
                        array_push ($errs, 'Sorry, 50 KB max');
                    }
                    elseif (file_exists ($dir . $name)) {
                        array_push ($errs, $name . ' bestaat al!');
                    }
                    else {
                        $path = $_SERVER['DOCUMENT_ROOT'] . '/' . $dir . $name;
                        if (is_uploaded_file ($tmp)) {
                            if (move_uploaded_file ($tmp, $path)) {
                                chmod ($path, 0644);
                                resize ($path, 568);
                                array_push ($msgs, 'Geupload: ' . $name);
                                array_push ($msgs, '<img style="border: 1px solid #000; " src="' . $dir . $name . '">');
                            }
                        }
                    }
                }
            }
        }
    ?>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>Jan Koehoorn | <?php echo $title; ?></title>
        
        <link rel="stylesheet" type="text/css" media="screen" href="reset.css" />
        <link rel="stylesheet" type="text/css" media="screen" href="oop.css" />
        <style type="text/css">
            form                    {padding: 10px;}
            ul.msgs                    {margin: 10px; padding: 10px; border: 2px solid #00f; background: #99f;}
            ul.errs                    {margin: 10px; padding: 10px; border: 2px solid #f00; background: #f99;}
            ul.msgs li,
            ul.errs li                {color: #000;}
        </style>
        
        <script type="text/javascript" src="mootools/mootools.js"></script>
        <script type="text/javascript">
            window.addEvent ('domready', function () {
                $$('a.add').each (function (item) {
                    item.addEvent ('click', function (e) {
                        e = new Event (e).preventDefault ();
                        var p = item.getParent ();
                        var clone = p.clone().injectBefore(p);
                        var a = clone.getLast ();
                        a.remove ();
                        var remove = document.createElement ('a');
                        remove.innerHTML = 'verwijderen';
                        remove.href = '#';
                        remove.addEvent ('click', function (e) {
                            e = new Event (e).preventDefault ();
                            this.getParent ().remove ();
                        });
                        clone.appendChild (remove);
                        var f = p.getFirst ();
                        f.value = '';
                    });
                });
            });
        </script>
    </head>
    
    <body>
        <div id="container">
            <h1>Jan Koehoorn | <?php echo $title; ?></h1>
            <p>Dit is een dynamisch multiple file upload script. Op deze manier kun je 1 of meer bestanden tegelijk uploaden.</p>
            <p>JPG only, 50 KB max</p>
            <?php
                if (!empty ($errs)) {
                    echo '<ul class="errs">';
                    foreach ($errs as $err) {
                        echo '<li>' . $err . '</li>';
                    }
                    echo '</ul>';
                }
                if (!empty ($msgs)) {
                    echo '<ul class="msgs">';
                    foreach ($msgs as $msg) {
                        echo '<li>' . $msg . '</li>';
                    }
                    echo '</ul>';
                }
            ?>
            <form id="my_form" method="post" action="<?php echo $_SERVER['REQUEST_URI']; ?>" enctype="multipart/form-data">
                <p>
                    <input name="userfile[]" type="file" size="60" /> <a class="add" id="toevoegen" href="#">toevoegen</a>
                </p>
                <p>
                    <input type="submit" value="upload" />
                </p>
            </form>
        </div>
    </body>
    </html>

  5. #25
    Join Date
    Jul 2006
    Location
    Antwerp, Belgium (Europe)
    Posts
    927
    Thanks
    121
    Thanked 2 Times in 2 Posts

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •