www.webdeveloper.com
Results 1 to 4 of 4

Thread: Help with image upload and email attachment

Threaded View

  1. #1
    Join Date
    Sep 2013
    Posts
    2

    Help with image upload and email attachment

    I am creating an online estimate form for a body shop. I need to collect information on the customer and image of vehicle, then email this info to the business email. I have to problem collect the form info an sending in email. I just don't know how to collect the uploads images and attach them to the outgoing email. This is what I have so far.
    PHP Code:
    <?php
    //include the header and set the title
    define('TITLE''Online Estimate Form');
    include(
    'templates/est_header.html');

    //check if the form has been submitted
    if ($_SERVER['REQUEST_METHOD'] == 'POST') {
        
    $okay FALSE;
        
        
    $title $_POST['title'];
        
    $fname $_POST['fname'];
        
    $lname $_POST['lname'];
        
    $phone $_POST['phone'];
        
    $email $_POST['email'];
        
    $make $_POST['make'];
        
    $model $_POST['model'];
        
    $year $_POST['year'];
        
    $vin $_POST['vin'];
        
    $mileage $_POST['mileage'];
        
    $tag $_POST['tag'];
        
    $description $_POST['description'];
        
        
    //Validate all required fields have been completed
        
    if ($title == 'Mr.') {
            
    $title_type 'Mr.';
        } elseif (
    $title == 'Mrs.') {
            
    $title_type 'Mrs.';
        } elseif (
    $title == 'Ms.') {
            
    $title_type 'Ms.';
        } else {
            print 
    '<p class="error">Please select a title for yourself</p>';
            
    $okay TRUE;
        }
        if (empty(
    $fname)) {
            print 
    '<p class="error">Please enter your first name</p>';
            
    $okay TRUE;
        }
        if (empty(
    $lname)) {
            print 
    '<p class="error">Please enter your last name</p>';
            
    $okay TRUE;
        }
        if (empty(
    $phone)) {
            print 
    '<p class="error">Please enter phone number</p>';
            
    $okay TRUE;
        }
        if (empty(
    $email)) {
            print 
    '<p class="error">Please enter your email address</p>';
            
    $okay TRUE;
        }
        if (empty(
    $make)) {
            print 
    '<p class="error">Please enter the make of your vehicle</p>';
            
    $okay TRUE;
            
        }
        if (empty(
    $model)) {
            print 
    '<p class="error">Please enter the model of your vehicle</p>';
            
    $okay TRUE;
        }
        if (empty(
    $year)) {
            print 
    '<p class="error">Please enter the year of your vehicle</p>';
            
    $okay TRUE;
        }
        if (empty(
    $vin)) {
            print 
    '<p class="error">Please enter the 17 digit VIN for your vehicle</p>';
            
    $okay TRUE;
        }
        if (empty(
    $mileage)){
            print 
    '<p class="error">Please enter the mileage of your vehicle</p>';
            
    $okay TRUE;
        }
        if (empty(
    $tag)) {
            print 
    '<p class="error">Please enter the tag number of your vehicle</p>';
            
    $okay TRUE;
        }
        if (empty(
    $description)) {
            print 
    '<p class="error">Please the required description of damage to your vehicle</p>';
            
    $okay TRUE;
        }
        if(!
    $okay) {
            
    //Print a confrimation message
            
    print "<p>Thank you $title_type $lname the information on the damage to your $year $make $model has been recieved.</p>";
            print 
    "<p> You will been contact by someone within our office within 3 business days about the estimate for repairs.</p>";
            print 
    '<p>If you have any question or concerns please feel free to contact us at 803.794.8351.</p>';
            print 
    '<p>Thank you for your business!</p>';
            print 
    '<img src="logo.png" alt="company logo" />';
            
            
    //Send the email
            
    $to  'midlandscollisioncenter@gmail.com'//. ', ';
            //$to .= 'robbiebedwell@yahoo.com';
            
    $subject "Estimate Request";
            
    $message "$title_type $fname $lname would like an estimate on repairs to their $year $make $model.\n
                They describe the damage to their vehicle as:\n
                    
    $description.\n
                    The vin is 
    $vin, mileage $mileage, tag number $tag.\n
                    They can be reached by phone at 
    $phone, or by email at $email.";
            
    mail($to,$subject,$message);
            
            
    //Clear the post items
            
    $_POST = array();
        } else {
            print 
    '<p style="color: red; font-weight: bold;">Please correct any missing information and try again!</p>';
        }
    }

    //Leave php to create the form
    ?>

    <h2>Free Online Estimate Form</h2>
    <p>Please enter the following information to submit an online estimate<br />
        <em>* Required fields</em></p>
    <form action="estimate.php" method="post">
        <p><em style="color: red; font-style: normal;">* </em>Title: <select name="title">
                <option value="Select One"></option>
                <option value="Mr.">Mr.</option>
                <option value="Mrs.">Mrs.</option>
                <option value="Ms.">Ms.</option>
            </select>
            <em>* </em>First Name: <input type="text" name="fname" size="20"/>
            <em>* </em>Last Name: <input type="text" name="lname" size="20" /></p>
        <p><em>* </em>Phone: <input type="tel" name="phone" /><em>* </em>Email: <input type="email" name="email" /></p>
        <p><em>* </em>Vehicle Make: <input type="text" name="make" size="20" />
            <em>* </em>Vehicle Model: <input type="text" name="model" size="20" />
            <em>* </em>Vehicle Year <input type="text" name="year" size="4" /></p>
        <p><em>* </em>VIN Number <input type="text" name="vin" size="17" />
            <em>* </em>Mileage: <input type="text" name="mileage" size="8" />
            <em>* </em>Tag #: <input type="text" name="tag" size="8" /><br />
            This is a 17 digit number located in the right front corner of your dash or on your vehicle registration card.</p>
        <p><em>* </em>Please describe the damage to your vehicle and circumstance which caused the damage. <br/>
            <textarea name="description" rows="10" cols="70"></textarea></p>
        <p><em>* </em>Please upload images of the damage to your vehicle. (see sidebar for tips on taking the best pictures)<br />
            <input type="file" name="image1" /><br />
        <input type="file" name="image2" /><br />
        <input type="file" name="image3" /><br />
        <input type="file" name="image4" /><br />
        <input type="file" name="image5" /></p>
        <p><input type="submit" value="Send" /></p>
    </form>

    <?php
    include('templates/footer.html');
    ?>
    Last edited by NogDog; 09-20-2013 at 12:06 PM. Reason: added [php] tags

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles