Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New to the CF scene
    Join Date
    Nov 2010
    Posts
    7
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Email Confirmation Script

    Hi!

    New here so hello!

    Im very new to PHP and am doing a PHP form for a client which when sent it sends the client an image attachment with the email. Also when the form is submitted they want a simple email to be sent to the user saying "Thanks for your email, we will contact you soon etc etc etc.."

    Here is the forms PHP script :

    PHP Code:
    <?PHP 

    require_once("./include/fgcontactform.php"); 

    $formproc = new FGContactForm(); 

    //1. Add your email address here. 
    //You can add more than one receipients. 
    $formproc->AddRecipient('scott@0design.co.uk'); //<<---Put your email address here 



    $formproc->SetFormRandomKey('HG9hPBpn9Bn26yg'); 

    $formproc->AddFileUploadField('photo','jpg,jpeg,gif,png,bmp',2024); 

    if(isset(
    $_POST['submitted'])) 

       if(
    $formproc->ProcessForm()) 
       { 
            
    $formproc->RedirectToURL("thank-you.html"); 
       } 



    $user $_POST['email'];
    $usersubject "Thank You"
    $userheaders "From: scott@0design.co.uk\n"
    $usermessage "Thank you for contacting us."

    mail($user,$usersubject,$usermessage,$userheaders); 


    ?> 
    <!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" xml:lang="en-US" lang="en-US"> 
    <head> 
          <meta http-equiv='Content-Type' content='text/html; charset=utf-8'/> 
          <title>Contact us</title> 
          <link rel="STYLESHEET" type="text/css" href="contact.css" /> 
          <script type='text/javascript' src='scripts/gen_validatorv31.js'></script> 
          <script type='text/javascript' src='scripts/fg_captcha_validator.js'></script> 
    </head> 
    <body> 

    <!-- Form Code Start --> 
    <form id='contactus' action='<?php echo $formproc->GetSelfScript(); ?>' method='post' enctype="multipart/form-data"> 

    <fieldset > 
    <legend>Contact us</legend> 

    <input type='hidden' name='submitted' id='submitted' value='1'/> 
    <input type='hidden' name='<?php echo $formproc->GetFormIDInputName(); ?>' value='<?php echo $formproc->GetFormIDInputValue(); ?>'/> 
    <input type='text'  class='spmhidip' name='<?php echo $formproc->GetSpamTrapInputName(); ?>' /> 

    <div class='short_explanation'>* required fields</div> 

    <div><span class='error'><?php echo $formproc->GetErrorMessage(); ?></span></div> 
    <div class='container'> 
        <label for='name' >Your Full Name*: </label><br/> 
        <input type='text' name='name' id='name' value='<?php echo htmlentities($_POST['name']) ?>' maxlength="50" /><br/> 
        <span id='contactus_name_errorloc' class='error'></span> 
    </div> 
    <div class='container'> 
        <label for='email' >Email Address*:</label><br/> 
        <input type='text' name='email' id='email' value='<?php echo htmlentities($email $_POST['email']) ?>' maxlength="50" /><br/> 
        <span id='contactus_email_errorloc' class='error'></span> 
    </div> 
    <div class='container'> 
        <label for='message' >Message:</label><br/> 
        <span id='contactus_message_errorloc' class='error'></span> 
        <textarea rows="10" cols="50" name='message' id='message'><?php echo htmlentities($_POST['message']) ?></textarea> 
    </div> 
    <div class='container'> 
        <label for='photo' >Upload your photo:</label><br/> 
        <input type="file" name='photo' id='photo' /><br/> 
        <span id='contactus_photo_errorloc' class='error'></span> 
    </div> 


    <div class='container'> 
        <input type='submit' name='Submit' value='Submit' /> 
    </div> 

    </fieldset> 
    </form> 



    </body> 
    </html>

    It works fine sending the email to the client with the image attachment, but I cant get the Confirmation email script to work!

    Any ideas on what ive done wrong? again am very new to this so sorry if its something simple!

    Thanks for your help!!!!

  • #2
    Senior Coder
    Join Date
    Jun 2008
    Location
    New Jersey
    Posts
    2,546
    Thanks
    45
    Thanked 259 Times in 256 Posts
    Is what you've shown the email to the client or the confirmation email? Because its only sending one email here. Unless that class is sending an email?

  • Users who have thanked Keleth for this post:

    shibbytude (11-03-2010)

  • #3
    New to the CF scene
    Join Date
    Nov 2010
    Posts
    7
    Thanks
    3
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Keleth View Post
    Is what you've shown the email to the client or the confirmation email? Because its only sending one email here. Unless that class is sending an email?
    Hi

    Thanks for the message.

    THe code i have shown is for the Client & Confirmation email.

    I havent done this before so probably got it all wrong!

    This code as far as im away is meant to send it to the User

    PHP Code:
    $user $_POST['email']; 
    $usersubject "Thank You";  
    $userheaders "From: scott@0design.co.uk\n";  
    $usermessage "Thank you for contacting us."
    This code is the one that is sent to the client :

    PHP Code:
    //1. Add your email address here.  
    //You can add more than one receipients.  
    $formproc->AddRecipient('scott@0design.co.uk'); //<<---Put your email address here 
    As said im really new to PHP and may have got the code for email confirmation totally wrong,

    When doing the code flat out with a test email like this :

    PHP Code:
    mail('scott@0design.co.uk','test message','this is a test message'); 
    It worked fine, im having trouble getting the script to take the email address from the form so it sends a confirmation to that email when submitted.

    Thanks again.

  • #4
    Senior Coder
    Join Date
    Jun 2008
    Location
    New Jersey
    Posts
    2,546
    Thanks
    45
    Thanked 259 Times in 256 Posts
    Right, ok.

    The issue, given from what I can see, is that you're trying to send the email AFTER the page redirects. Kind of like saying, I'll lock my house AFTER I'm already in my car. Not really doable. So move your email script up above the redirect.

  • Users who have thanked Keleth for this post:

    shibbytude (11-03-2010)

  • #5
    New to the CF scene
    Join Date
    Nov 2010
    Posts
    7
    Thanks
    3
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Keleth View Post
    Right, ok.

    The issue, given from what I can see, is that you're trying to send the email AFTER the page redirects. Kind of like saying, I'll lock my house AFTER I'm already in my car. Not really doable. So move your email script up above the redirect.
    It works!!!!

    lol

    Thanks so much for your help and for the funny way of explaining it

    Much appreciated! are a life saver!!

    Thanks again!!!!


  •  

    Posting Permissions

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