Page 2 of 4 FirstFirst 1234 LastLast
Results 11 to 20 of 33

Thread: Confirmation Email PHP Sender

  1. #11
    Join Date
    Feb 2006
    Posts
    227
    Thanks
    7
    Thanked 3 Times in 3 Posts

    Default

    Well, I see that it is the second email that is failing; the first gets through. The second email call does not have the variable '$headers', and therefore no 'from' in the email function, so it will NEVER be sent (unless you have an override in php.ini, and I don't think you do.) Why don't you read-up on the php mail function first? See: http://php.net/manual/en/function.mail.php And, BTW, you have some unused variables in your script. There is no validation, as mentioned before by the moderators. There are dozens of more advanced scripts on the web, so after you get this running, put in all the basics about field validation.

  2. #12
    Join Date
    Aug 2013
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Contact Form W/ Confirmation Email?

    Hello,
    I have been trying to make a basic form with a First Name, Last Name, Email, and Invitation Code fields. Then once the submit button has been clicked it will send me the info they entered and there email will get a "Thank you" email. The main problem with this is the template that I am using, It doesn't want to work with random codes. I was using a very confusing Ajax / JS way to make the email send but no luck with the confirmation. So I am starting from scratch and seeing that I cant seem to find any help online about confirmations I though I would ask here. I want to keep it basic so I can easily edit the code for other forms that I may need. The template is in HTML but the index page is linked to every other HTML page using the code in the index.html file head tag for every HTML page.

    Here is the template that I am using:

    http://www.renklibeyaz.com/rightnow/


    Thank you and any help is much appreciated.

  3. #13
    Join Date
    Aug 2013
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    I am currently trying to use this code but it wont send the info just he subject names.

    Form:
    PHP Code:
    <form name="htmlform" method="post" action="send.php">
    <
    table width="450px">
    </
    tr>
    <
    tr>
     <
    td valign="top">
      <
    label for="fname">First Name:</label></td>
     <
    td valign="top">
      <
    input  type="text" name="fname" maxlength="50" size="30">
     </
    td>
    </
    tr>
     
    <
    tr>
     <
    td valign="top">
      <
    label for="lname">Last Name: </label>
     </
    td>
     <
    td valign="top">
      <
    input  type="text" name="lname" maxlength="50" size="30">
     </
    td>
    </
    tr>
    <
    tr>
     <
    td valign="top">
      <
    label for="email">Email Address: </label></td>
     <
    td valign="top">
      <
    input  type="text" name="email" maxlength="80" size="30">
     </
    td>
     
    </
    tr>
    <
    tr>
     <
    td valign="top">
      <
    label for="email1">Invitation Code:</label></td>
     <
    td valign="top">
      <
    input  type="text" name="email1" maxlength="30" size="30">
     </
    td>
    </
    tr>

    <
    tr>
     <
    td colspan="2" style="text-align:center">
      <
    input type="submit" value="Register">
     </
    td>
    </
    tr>
    </
    table>
    </
    form

    Send.php file:
    PHP Code:
    <?php
      

        

    $ip
    =$_SERVER['REMOTE_ADDR'];
          
    $email_to "info@mywebsite.com";
          
    $email_subject "Registration";
      

        

    $email_message .= "First Name Entered: ".$_POST["fname"]."\n";
      

        

    $email_message .= "Last Name Entered: ".$_POST["lname"]."\n";
      

        

    $email_message .= "Email Entered: ".$_POST["email"]."\n";
      

        

    $email_message .= "Invitation Code: ".$_POST["email1"]."\n";







        
          
          
     

        

    //email headers
     

        

    $headers 'From: '.$_POST["email"]."\r\n".
     

        

    'Reply-To: '.$_POST["email"]."\r\n" .
     

        

    'X-Mailer: PHP/' phpversion();
     

        

    echo (
    mail($email_to$email_subject$email_message$headers) ? "Sent to mywebsite""failed sending to website");

     echo (
    mail($email_to$email_subject$email_message$headers) ? "Sent to mywebsite""failed sending to website");

        

    die();
     
    ?>
    Last edited by itskater; 09-03-2013 at 10:02 PM.

  4. #14
    Join Date
    Jan 2007
    Location
    Davenport, Iowa
    Posts
    1,702
    Thanks
    82
    Thanked 90 Times in 88 Posts

    Default

    itskater, it is good to start a new thread when you have a separate question that does not quite relate to your current problem, but it is not necessary to create new thread to post new developments in your current project. If I am misunderstanding why you are creating new threads please let me know.
    To choose the lesser of two evils is still to choose evil. My personal site

  5. #15
    Join Date
    Aug 2013
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Thank you. That is the updated code, I'm just working on the confirmation now. I think you guys can help now since that other code was confusing since it was linking to so many other different codes and languages. Now it is just HTML and PHP.
    Last edited by itskater; 09-03-2013 at 10:23 PM.

  6. #16
    Join Date
    Aug 2013
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    So I guess my final question is... How can I edit this code so that it will send a second email to the "email" associated with this code
    PHP Code:
    $email_message .= "Email Entered: ".$_POST["email"]."\n"
    Also in the email subject to say "Thank you" and then in the Body of the email say "Thank you for registering"
    Do I need to enter in a second set of $headers? or maybe duplicate the whole <?php tag? I'm assuming I'm almost there just a small twitch to get it to work.

    Thank you to everyone helping.

    ___________________________________________________________________________________

    I am so close!

    I can get the email to send to my email and another exactly how I want but I can not set it up so that the other email is the email that the user entered. I set it so that it was my email for the first one and another email I have for the second and received both. But I don't know how to make it so that the email entered is the email that will receive the Thank you email.

    PHP Code:
    <?php
      

        

    $ip
    =$_SERVER['REMOTE_ADDR'];
          
    $email_to "info@mywebsite.com";
          
    $email_subject "Registration";
      

        

    $email_message .= "First Name Entered: ".$_POST["fname"]."\n";
      

        

    $email_message .= "Last Name Entered: ".$_POST["lname"]."\n";
      

        

    $email_message .= "Email Entered: ".$_POST["email"]."\n";
      

        

    $email_message .= "Invitation Code: ".$_POST["email1"]."\n";


    //email headers
     

        

    $headers 'From: '.$_POST["email"]."\r\n".

    'Reply-To: '.$_POST["email"]."\r\n" .

    'X-Mailer: PHP/' phpversion();
     

        

    echo (
    mail($email_to$email_subject$email_message$headers) ? "Sent":"Fail");









    $ip=$_SERVER['REMOTE_ADDR'];
          
    $email_to "me@myemail2.com";
          
    $email_subject "Thank you | Code Events";
      
    $email_message1 "Thank you!";



    //email headers
     

        

    $headers 'From: '.$_POST["email"]."\r\n".

    'Reply-To: '.$_POST["email"]."\r\n" .

    'X-Mailer: PHP/' phpversion();
     

        

    echo (
    mail($email_to$email_subject$email_message1$headers) ? "Sent":"Fail");



        

    die();



     
    ?>
    Last edited by itskater; 09-03-2013 at 11:08 PM.

  7. #17
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,162
    Thanks
    263
    Thanked 690 Times in 678 Posts

    Default

    You should look at the documentation for mail(). Since you know what parameters are required (the email address, the text, etc.), you should be able to just fill those into that function as needed. Simply add that as a new line in the code, with the right arguments, and it will send another email. There's nothing magical about sending email in PHP, although it does need a little set up before you can send the email (such as where you're sending it). If you don't need any dynamic (changing/user-input) values, you can just use a single line with all of the information as text, and that will work.

    Again, you haven't addressed my earlier questions, including about your experience with PHP-- so I don't know if I need to explain in a lot of detail (for example, you might have no idea what a "function" is) or just outline in general terms because you can figure out the rest. It isn't a problem either way-- you might know just the basics, or you might know a lot. But either way, knowing that will help me to help you...



    By the way, you still don't seem to be using any kind of email address verification (as traq suggested above). That's a very bad idea, but it's up to you. (The consequences can range from errors when processing the script to even having your server blacklisted for sending emails, because too many of your attempted emails are not reaching a destination.)
    One simple way to validate an email address is:
    http://php.net/manual/en/function.filter-var.php
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  8. #18
    Join Date
    Aug 2013
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Hello djr33,
    I know HTML very well but PHP I am still learning. I know the basics and how to usually get things to work like I want. I did research the mail() function and I see how to use it but the final question I am asking I couldn't find online. Can I use a code to take this code entry:
    PHP Code:
    $email_message .= "Email Entered: ".$_POST["email"]."\n"

    and automatically put the entry into where it says "me@myemail.com"
    PHP Code:
          $email_to "me@myemail.com"
    I think I need to some how associate it to the "email' but I can not find a helpful code. I will try and add the verification after I have successfully added the confirmation.

    Thank you.

  9. #19
    Join Date
    Aug 2013
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    RESOLVED!

    Here is the code:
    PHP Code:
    $email_to $_POST["email"]; 

  10. #20
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,162
    Thanks
    263
    Thanked 690 Times in 678 Posts

    Default

    You can use $_POST['X'] anywhere you can use $X, so it's up to you how you want to arrange it.

    Something like this would work:
    mail($_POST['X'],'Hello','Body text...',$headers);

    I'd suggest reading through the code a lot more carefully to understand what each part does. The structure of PHP is not very complicated, and once you understand things like functions and arguments you'll be able to do a lot more with the code. (I'm not complaining that you're still learning-- that's good, there's a lot to learn, but you'll get there.)
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

Similar Threads

  1. Email Auto-Confirmation
    By misslilly1991 in forum PHP
    Replies: 0
    Last Post: 11-08-2011, 10:42 PM
  2. Adding a confirmation email?
    By Bengal313 in forum PHP
    Replies: 2
    Last Post: 08-05-2010, 06:53 PM
  3. php email confirmation...
    By lirhahs in forum PHP
    Replies: 15
    Last Post: 06-10-2010, 09:27 AM
  4. Simple Email Confirmation/OR cc form
    By almcaffee in forum JavaScript
    Replies: 2
    Last Post: 12-08-2009, 01:27 PM
  5. Sending email confirmation
    By Tayfun in forum PHP
    Replies: 4
    Last Post: 08-12-2009, 08:37 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
  •