my email form is not working right

Discussion in 'PHP' started by stickycarrots, Mar 5, 2008.

  1. #1
    here is the html
    <form method="post" action="mes.php" name="form">
    <table>
    <tr><td>First Name: </td><td><input type="text" name="fname" /></td></tr>
    <tr><td>Last Name: </td><td><input type="text" name="lname" /></td></tr>
    <tr><td>E-Mail: </td><td><input type="text" name="email" /></td></tr>
    <tr><td>Message: </td><td><textarea name="tmessage" col="10" rows="4"></textarea></td></tr>
    <tr><td>Type of Message: </td><td>	<input type="radio" name="mtype" value="prayer" checked="checked"> Prayer Request <br/>
    <input type="radio" name="mtype" value="message"> Message</td></tr>
    <tr><td></td><td><input type="submit" name="submit" value="Send Message" /></td></tr>													</table>
    </form>
    Code (markup):
    here is the php
    <?PHP
    
    $fname = $_POST['fname'];
    $lname = $_POST['lname'];
    $email = $_POST['email'];
    $tmessage = $_POST['tmessage'];
    $mtype = $_POST['mtype'];
    
    mail('info@findnewlife.com', $mytype . ' for NewLife', $tmessage);
    
    
    ?>
    Code (markup):
    its just sending the Message part nothing else thanks for the help
     
    stickycarrots, Mar 5, 2008 IP
  2. 9450184

    9450184 Peon

    Messages:
    30
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Well, it's because you only send the Message part!
    You need to include headers:

    $headers = "From: $fname <$email>\n";
    mail('info@findnewlife.com', $mytype . ' for NewLife', $tmessage, $headers);
    PHP:
    Or you could include that data into your message..
     
    9450184, Mar 5, 2008 IP
  3. stickycarrots

    stickycarrots Peon

    Messages:
    4,513
    Likes Received:
    115
    Best Answers:
    0
    Trophy Points:
    0
    #3
    will the last name work too
     
    stickycarrots, Mar 5, 2008 IP
  4. Codythebest

    Codythebest Notable Member

    Messages:
    5,764
    Likes Received:
    253
    Best Answers:
    0
    Trophy Points:
    275
    #4
    Yes if you add it

    $headers = "From: $fname $lname <$email>\n";
    mail('info@findnewlife.com', $mytype . ' for NewLife', $tmessage, $headers);
     
    Codythebest, Mar 5, 2008 IP
  5. stickycarrots

    stickycarrots Peon

    Messages:
    4,513
    Likes Received:
    115
    Best Answers:
    0
    Trophy Points:
    0
    #5
    how do i make it show up in the email and is there a way to make the title of the message one of the 2 thing you can pick on the menu Prayer Request or Message
     
    stickycarrots, Mar 5, 2008 IP
  6. 9450184

    9450184 Peon

    Messages:
    30
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Change

    <tr><td>Type of Message: </td><td>	<input type="radio" name="mtype" value="prayer" checked="checked"> Prayer Request <br/>
    <input type="radio" name="mtype" value="message"> Message</td></tr> 
    HTML:
    to

    <tr><td>Type of Message: </td><td>	<input type="radio" name="mtype" value="Prayer Request" checked="checked"> Prayer Request <br/>
    <input type="radio" name="mtype" value="Message"> Message</td></tr>
    HTML:
    <?PHP
    
    $fname = $_POST['fname'];
    $lname = $_POST['lname'];
    $email = $_POST['email'];
    $tmessage = $_POST['tmessage'];
    $mtype = $_POST['mtype'];
    $headers = "From: $fname $lname <$email>\n";
    
    mail('info@findnewlife.com', $mytype . ' for NewLife', 'Name: ' . $fname . ' ' . $lname . '\nEmail: ' .$email. '\nMessage: ' . $tmessage, $headers);
    
    ?>
    PHP:
     
    9450184, Mar 5, 2008 IP
  7. ChitikaGuide.Com

    ChitikaGuide.Com Peon

    Messages:
    32
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #7
    mail($to, $MySubject, $MyMessage, $from);

    Just create the variables to what you want.

    $MySubject = stripslashes($_POST[Subject]);
     
    ChitikaGuide.Com, Mar 5, 2008 IP