Results 1 to 2 of 2

Thread: Php form auto respond

  1. #1
    Join Date
    Nov 2012
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Php form auto respond

    Hi everyone,
    Please i have a php script form that send attachement but i want it to also send an auto reply the users after filling out the form please can someone help me with the direction to do so, below is the php code for the form.. Thanks a million

    PHP Code:
    <?php

    function mail_file($to$from$subject$body$file){
          
    $boundary md5(rand());

          
    $headers = array(
          
    'MIME-Version: 1.0',
    "Content-Type: multipart/mixed; boundary=\"{$boundary}\"",
    "From: {$from}"
    );

    $message = array(
    "--{$boundary}",
    'Content-Type: text/plain',
    'Content-Transfer-Encoding: 7bits',
    '',
    chunk_split($body),
    "--{$boundary}",
    "Content-Type:{$file['type']}; name=\"{$file['name']}\"",
    "Content-Disposition: attachment; filename=\"{$file['name']}\"",
    "Content-Transfer-Encoding: base64",
    '',
    chunk_split(base64_encode(file_get_contents($file['tmp_name']))),
    "--{$boundary}--"
    );

    mail($to$subjectimplode("\r\n"$message), implode("\r\n"$headers));


    header('Location: contact-form-thank-you.html');

    if (isset(
    $_POST['firstname'], $_POST['lastname'], $_POST['company'], $_POST['address'], $_POST['phone'], $_POST['email'], $_POST['capacity'], $_FILES['file'])){
        
    $body = <<<BODY
                  First Name: {$_POST['firstname']}
                  Last Name: 
    {$_POST['lastname']}
                  Company Name: 
    {$_POST['company']}
                  Address: 
    {$_POST['address']}
                  Phone Number: 
    {$_POST['phone']}
                  Email Address: 
    {$_POST['email']}
                  Capacity: 
    {$_POST['capacity']}

    Details:  
    Name: 
    {$_FILES['file']['name']}
    Size: 
    {$_FILES['file']['size']}
    Type: 
    {$_FILES['file']['type']}

    BODY;


    mail_file('sales@mydomain.com''sales@mydomain.com''AGENTS FORM'$body$_FILES['file']);
    }
    ?>
    Last edited by keyboard; 11-30-2012 at 10:53 PM. Reason: Format: Php Tags [php][/php]

  2. #2
    Join Date
    Mar 2011
    Location
    N 11 19' 0.0012 E 142 15' 0
    Posts
    1,509
    Thanks
    41
    Thanked 89 Times in 88 Posts
    Blog Entries
    3

    Default

    What do you mean by auto-reply the users?
    Do you mean display some text in the users browser?
    Just use echo inside the if statement.

    Also, there's no validation on that... That script doesn't check if their email and so forth is valid.
    Also, if all the fields aren't set, it'd just display an empty screen instead of telling the user to fill in all the fields... That might be something to look into.

Similar Threads

  1. Auto Save Form Processing Previous Form Submission
    By Meleo in forum Dynamic Drive scripts help
    Replies: 3
    Last Post: 07-09-2012, 04:38 AM
  2. Replies: 0
    Last Post: 04-04-2010, 05:45 AM
  3. Auto Form
    By bluewalrus in forum HTML
    Replies: 2
    Last Post: 02-21-2008, 06:48 PM
  4. Replies: 1
    Last Post: 10-04-2007, 05:54 AM
  5. Auto Form (Dynamic)
    By jbrown1028 in forum JavaScript
    Replies: 9
    Last Post: 10-27-2006, 03:54 PM

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
  •