php script for mail form - question -

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • cartoonsmart

    php script for mail form - question -

    Hi I got the following script going;

    <?php
    $sendTo = "myemail@myemai l.com";
    $subject = "My web site reply";

    $headers = "From: " . $_POST["name"];
    $headers .= "<" . $_POST["email"] . ">\r\n";
    $headers .= "Reply-To: " . $_POST["email"] . "\r\n";
    $headers .= "Return-Path: " . $_POST["email"];
    $message = $_POST["message"];
    mail($sendTo, $subject, $message, $headers);
    ?>

    It's simple and save and I'm not really into php (yet!)...
    However I have a question regarding my script.
    In the Email body/message I receive after the form is filled in and
    submited
    I only see the message - obvousily because of this line $message =
    $_POST["message"]; -
    Now I would like to receive to name and email address in mail
    body/message to.
    How do I go about to achieve this, I've tried the following...

    $message = $_POST["name"];
    $message = $_POST["email"];

    after I added the above two lines it didn't result in anything.
    Anyone wanna fill me in on how I can put this to work.
    Thank, appreciate it!

  • Jonathan N. Little

    #2
    Re: php script for mail form - question -

    cartoonsmart wrote:[color=blue]
    > Hi I got the following script going;
    >
    > <?php
    > $sendTo = "myemail@myemai l.com";
    > $subject = "My web site reply";
    >
    > $headers = "From: " . $_POST["name"];
    > $headers .= "<" . $_POST["email"] . ">\r\n";
    > $headers .= "Reply-To: " . $_POST["email"] . "\r\n";
    > $headers .= "Return-Path: " . $_POST["email"];
    > $message = $_POST["message"];
    > mail($sendTo, $subject, $message, $headers);
    > ?>
    >
    > It's simple and save and I'm not really into php (yet!)...
    > However I have a question regarding my script.
    > In the Email body/message I receive after the form is filled in and
    > submited
    > I only see the message - obvousily because of this line $message =
    > $_POST["message"]; -
    > Now I would like to receive to name and email address in mail
    > body/message to.
    > How do I go about to achieve this, I've tried the following...
    >
    > $message = $_POST["name"];
    > $message = $_POST["email"];
    >
    > after I added the above two lines it didn't result in anything.
    > Anyone wanna fill me in on how I can put this to work.
    > Thank, appreciate it!
    >[/color]
    In a word 'concatenation' , need to look up concatenation of strings

    $myvar = 'I am this';
    echo $myvar; //displays 'I am this'

    $myvar = 'I am this';
    $myvar = ' and I am that';
    echo $myvar; //now displays only ' and I am that'

    $myvar = 'I am this';
    $myvar .= ' and I am that';
    echo $myvar; //now displays 'I am this and I am that'


    Also your code is just a strip down example, right? You are not really
    doing the code exactly like this:
    [color=blue]
    > $headers = "From: " . $_POST["name"];
    > $headers .= "<" . $_POST["email"] . ">\r\n";[/color]

    if so, stop and do a little research on security...




    --
    Take care,

    Jonathan
    -------------------
    LITTLE WORKS STUDIO

    Comment

    Working...