Results 1 to 4 of 4

Thread: How do I fix code so emails arrive showing the email field in the "TO" inbox?

  1. #1
    Join Date
    Mar 2007
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question How do I fix code so emails arrive showing the email field in the "TO" inbox?

    Hello. With my previous host provider, I'd used a CGI script. This one uses PHP, and they provide the PHP script. I've made all the necessary changes to my form to accomodate their script, however, I have one problem:

    Utilizing their script (below), how do I direct the emails to show the email address of the sender? IOW, one of the fields on the form is the email field. On my previous server, it was setup to show the email address field, when I received the email - it would appear to "come" from that person's email address. This was very useful to us for a few reasons.

    What do I need to add to my form, or to this script, in order to make it arrive as noted above?

    <?php
    $request_method = $_SERVER["REQUEST_METHOD"];
    if($request_method == "GET"){
    $query_vars = $_GET;
    } elseif ($request_method == "POST"){
    $query_vars = $_POST;
    }
    reset($query_vars);
    $t = date("U");

    $file = $_SERVER['DOCUMENT_ROOT'] . "/../data/gdform_" . $t;
    $fp = fopen($file,"w");
    while (list ($key, $val) = each ($query_vars)) {
    fputs($fp,"<GDFORM_VARIABLE NAME=$key START>\n");
    fputs($fp,"$val\n");
    fputs($fp,"<GDFORM_VARIABLE NAME=$key END>\n");
    if ($key == "redirect") { $landing_page = $val;}
    }
    fclose($fp);
    if ($landing_page != ""){
    header("Location: http://".$_SERVER["HTTP_HOST"]."/$landing_page");
    } else {
    header("Location: http://".$_SERVER["HTTP_HOST"]."/");
    }


    ?>


    Thanks!

  2. #2
    Join Date
    Feb 2007
    Posts
    116
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    mail( [to], [subject], [message], "From: [from]" );

    [to] - the email you're sending the message to.
    [subject] - the message subject.
    [message] - the message body
    [from] - the email address you want the message to be from.

    Here's an example:

    Code:
    $from = "me@somewhere.com";
    $to = "you@somewhereelse.com";
    $message = "I bent my wookie!";
    $subject = "Hello there!";
    
    mail($to, $subject, $message, "From: $from");
    "Rock and roll ain't noise pollution." - AC/DC

    http://www.blake-foster.com

  3. #3
    Join Date
    Mar 2007
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    But, that would give the same email address all the time? That is, if I'm reading it correctly.

    I'd like it to give the email address that the person fills in on the form.

  4. #4
    Join Date
    Feb 2007
    Posts
    116
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    That's exactly what it does. It's only meant to be an example. Instead of putting in the same email address every time, you'll need to retrieve the email that the user entered in the form.

    For example, if the field's name is email, you would write

    Code:
    $from = $_REQUEST['email'];
    "Rock and roll ain't noise pollution." - AC/DC

    http://www.blake-foster.com

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
  •