Results 1 to 9 of 9

Thread: php form auto response

  1. #1
    Join Date
    Oct 2007
    Posts
    47
    Thanks
    0
    Thanked 1 Time in 1 Post

    Default php form auto response

    Hello there

    I've got a php form designed to request simple information from web site traffic (their name, address etc, email ) - how complicated is it to generate an automatic email response to say thanks to those who have completed the form?

    Thanks
    H

  2. #2
    Join Date
    Mar 2007
    Location
    Tarboro, NC
    Posts
    290
    Thanks
    8
    Thanked 2 Times in 2 Posts

    Default

    Not hard at all, just do what you did with the mail() to send it to you, something like this will do.

    Code:
    $name=$_POST['name'];
    $email=$_POST['email'];
    $message=$_POST['message'];
    $autoreply="Thank you for your time, $name. Your message/comment is replied to you
    below\n\n$message\n\nThis is an automated reply.";
    $subject="Thank you for your submission $name!";
    
    mail($email, $subject, $autoreply);
    Of course it would need to be edited so as no conflicts with yours, and so that it goes with what your form names are, your message, etc. It should work though.

    Tim

  3. #3
    Join Date
    Oct 2007
    Posts
    47
    Thanks
    0
    Thanked 1 Time in 1 Post

    Default

    Tim

    Thanks for the response - I've had a go (several actually) at getting this to work but something's going wrong as I'm not getting the autoresponse

    Could you point me in the right direct by any chance.

    Cheers
    H

  4. #4
    Join Date
    Mar 2007
    Location
    Tarboro, NC
    Posts
    290
    Thanks
    8
    Thanked 2 Times in 2 Posts

    Default

    I'm having problems looking up the mail() function, mail.google.com and mail.yahoo.com are there to much lol. Anyways, it just it me can mail even be used more than once? In the same script that is...

  5. #5
    Join Date
    Sep 2006
    Location
    St. George, UT
    Posts
    2,769
    Thanks
    3
    Thanked 157 Times in 155 Posts

    Default

    Actually, yes it can be used as many times as you need it to. Here is what you need to do to your script:

    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
    
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
    <title>Sendemail Script</title>
    </head>
    <body>
    
    <?php
    
    $ip = $_POST['ip']; 
    $httpref = $_POST['httpref']; 
    $httpagent = $_POST['httpagent']; 
    $visitor = $_POST['visitor']; 
    $visitormail = $_POST['visitormail']; 
    $notes = $_POST['notes'];
    $attn = $_POST['attn'];
    
    
    if (eregi('http:', $notes)) {
    die ("Do NOT try that! ! ");
    }
    if(!$visitormail == "" && (!strstr($visitormail,"@") || !strstr($visitormail,"."))) 
    {
    echo "<h2>Use Back - Enter valid e-mail</h2>\n"; 
    $badinput = "<h2>Feedback was NOT submitted</h2>\n";
    echo $badinput;
    die ("Go back! ! ");
    }
    
    if(empty($visitor) || empty($visitormail) || empty($notes )) {
    echo "<h2>Use Back - fill in all fields</h2>\n";
    die ("Use back! ! "); 
    }
    
    $todayis = date("l, F j, Y, g:i a") ;
    
    $attn = $attn ; 
    $subject = $attn; 
    
    $notes = stripcslashes($notes); 
    
    $message = " $todayis [EST] \n
    Attention: $attn \n
    Message: $notes \n 
    From: $visitor ($visitormail)\n
    Additional Info : IP = $ip \n
    Browser Info: $httpagent \n
    Referral : $httpref \n
    ";
    
    $from = "From: $visitormail\r\n";
    
    
    $autoTo = "me@mydomain.com";
    $autoreply = "Thanks for you submission!"; //change this to your message
    
    mail($autoTo, "Auto Reply Subject", $autoreply, 'From: noreply@domain.com');
    
    
    mail("email@email.co.uk", $subject, $message, $from);
    
    
    ?>
    
    <p align="center">
    Date: <?php echo $todayis ?> 
    <br />
    Thank You : <?php echo $visitor ?> ( <?php echo $visitormail ?> ) 
    <br />
    
    Attention: <?php echo $attn ?>
    <br /> 
    Message:<br /> 
    <?php $notesout = str_replace("\r", "<br/>", $notes); 
    echo $notesout; ?> 
    <br />
    <?php echo $ip ?> 
    
    <br /><br />
    <a href="http://www.google.co.uk"> Next Page </a> 
    </p> 
    
    </body>
    </html>
    Hope this helps.
    "Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian Wilson, Nintendo, Inc, 1989
    TheUnlimitedHost | The Testing Site | Southern Utah Web Hosting and Design

  6. #6
    Join Date
    Oct 2007
    Posts
    47
    Thanks
    0
    Thanked 1 Time in 1 Post

    Default

    That's cracked it - brilliant. Thanks

  7. #7
    Join Date
    Oct 2008
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Im having trouble

    Hi everyone, i was just wondering if someone could give me a starting point on where to begin with the auto responder. I have done some research into auto response in PHP but cant get my head around it.

    I have a basic contact form which sends to the mailer, but i need it to send an auto response, can anyone help?

    PHP Code:
    <?php

    $myemail  
    "Myemailgoes here";


    $yourname check_input($_POST['yourname'], "Enter your name");
    $email    check_input($_POST['email'], " Enter your email");
    $number  check_input($_POST['number']);
    $comments check_input($_POST['comments']);


    if (!
    preg_match("/([\w\-]+\@[\w\-]+\.[\w\-]+)/"$email))
    {
        
    show_error("E-mail address not valid");
    }


    $messageone "Hello!

    Your contact form has been submitted by:

    Name: 
    $yourname
    E-mail: 
    $email
    number: 
    $number



    Comments:
    $comments

    End of message
    "
    ;

    $messagetwo "contact info";

    mail($myemail$messagetwo$messageone);

    header('Location: index.html');
    exit();



    function 
    check_input($data$problem='')
    {
        
    $data trim($data);
        
    $data stripslashes($data);
        
    $data htmlspecialchars($data);
        if (
    $problem && strlen($data) == 0)
        {
            
    show_error($problem);
        }
        return 
    $data;
    }

    function 
    show_error($myError)
    {
    ?>
        <html>
        <body>

        <b>Please correct the following error:</b><br />
        <?php echo $myError?>

        </body>
        </html>
    <?php
    exit();
    }
    ?>

  8. #8
    Join Date
    Oct 2008
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default I have added a little code

    I have added a little code to the bottom of my code, and to no avail. If anyone could help me that would be great
    PHP Code:
    <?php

    $myemail  
    "martin.s.kilner@googlemail.com";


    $yourname check_input($_POST['yourname'], "Enter your name");
    $email    check_input($_POST['email'], " Enter your email");
    $number  check_input($_POST['number']);
    $comments check_input($_POST['comments']);

    $from_name "Martin Kilner";

    $headers "From: {$from_name} <{$myemail}>"


    if (!
    preg_match("/([\w\-]+\@[\w\-]+\.[\w\-]+)/"$email))
    {
        
    show_error("E-mail address not valid");
    }


    $messageone "Hello!

    Your contact form has been submitted by:

    Name: 
    $yourname
    E-mail: 
    $email
    number: 
    $number



    Comments:
    $comments

    End of message
    "
    ;

    $messagetwo "contact info";

    mail($myemail$messagetwo$messageone);

    header('Location: index.html');
    exit();



    function 
    check_input($data$problem='')
    {
        
    $data trim($data);
        
    $data stripslashes($data);
        
    $data htmlspecialchars($data);
        if (
    $problem && strlen($data) == 0)
        {
            
    show_error($problem);
        }
        return 
    $data;
    }

    function 
    show_error($myError)
    {





    $messagethree "Thank You for your submission";

    $subject "Received";

    $headers "From: {$from_name} <{$myemail}>";

    mail($_REQUEST['email'],$subject,$messagethree,$headers);

    ?>
        <html>
        <body>

        <b>Please correct the following error:</b><br />
        <?php echo $myError?>

        </body>
        </html>
        
        
    <?php
    exit();
    }
    ?>
    If anyone could help me out, i would appreciate it. been trying to figure it out for ages now.

  9. #9
    Join Date
    Dec 2007
    Posts
    17
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    Hey, just wondering if you've received an answer on this...I'm looking to generate an email to a user who has filled out my form as well...

    Let me know, thanks!

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
  •