1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Need help with mailing form with php

Discussion in 'BlackHat Lounge' started by TrickaC14, Aug 25, 2010.

  1. TrickaC14

    TrickaC14 Registered Member

    Joined:
    Jul 23, 2008
    Messages:
    67
    Likes Received:
    22
    PHP:
    if($_POST['name']!='' && $_POST['company']!='' && $_POST['telephone']!='' && $_POST['e_mail']!='' && valid_email($_POST['e_mail'])==TRUE && strlen($_POST['message'])>30)
        {
            
    $to '[email protected]';
            
    $headers =     'From: '.$_POST['e_mail'].''"\r\n" .
                    
    'Reply-To: '.$_POST['e_mail'].'' "\r\n" .
                    
    'X-Mailer: PHP/' phpversion();
            
    $subject "Message";
            
    $message htmlspecialchars($_POST['message']);
    Right now when the contact form is submitted it only sends the message, I want all of the other info to be in the email as well like, company, the persons name, phone number, etc, with this info how would i get it to send the other info as well? Thanks
     
  2. The Scarlet Pimp

    The Scarlet Pimp Senior Member

    Joined:
    Apr 2, 2008
    Messages:
    883
    Likes Received:
    3,320
    Occupation:
    Chair moistener.
    Location:
    Cyberspace
  3. shin610

    shin610 Regular Member

    Joined:
    Jun 23, 2010
    Messages:
    224
    Likes Received:
    89
    You have to add to the variable $message the other data you want.

    For example the following code adds a new line to the message with the company name (first row) and another line with the name (second row):


    PHP:
    $message .= '\nCompany name:'.htmlspecialchars($_POST['company']);
    $message .= '\nName:'.htmlspecialchars($_POST['name']);
    and so on..

    repeat for all the data you need.

    (and hit thanks if it works lol)
     
    • Thanks Thanks x 1
  4. TrickaC14

    TrickaC14 Registered Member

    Joined:
    Jul 23, 2008
    Messages:
    67
    Likes Received:
    22
    Oh hell yea dude that worked, thanks a lot. Would you know how I could set up a template for this like to make it laid out nice to read in an email instead of bunched together? If not that's fine this helped me out a lot.
     
  5. shin610

    shin610 Regular Member

    Joined:
    Jun 23, 2010
    Messages:
    224
    Likes Received:
    89
    Well you can format the plain text email using

    \t for a tab
    \n for a newline


    or send an html email adding the following to the headers

    PHP:
    $headers .= "Content-type: text/html\r\n"