Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Jan 2008
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Add customer name to subject line of form submission email?

    Hello,

    I'm using gdform.php from godaddy to email forward form submission information from my website.

    I would like a way to grab the information from one of the form fields (customer's name) and have it added to the subject line of the email I get. (or failing that, add some other unique identifying stamp)

    Any suggestions? Thank you very much.

    I am not much of a coder - I've just messed around a bit. (so spell it out please, I'm quick, but not much background)

    the html line that references gdform and defines email subject line is:

    <form name="Form1" method="post" action="http://www.mywebsite.com/gdform.php" enctype="multipart/form-data" id="Form1" onsubmit="return ValidateForm1(this)" ><input type="hidden" name="redirect" value="purchase.html"><input type="hidden" name="subject" value="Order Information">

    gdform script is:

    <?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"]."/");
    }


    ?>

  • #2
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,987
    Thanks
    4
    Thanked 2,660 Times in 2,629 Posts
    No.
    No seriously though, we don't have enough here to really help all that much, and I'm not familiar with the GD script thingies.
    What I can tell you is this.
    If the subject line comes from one of your submissions (name="subject"?) for example, you can control what goes in there. So, say the run against a subject message of "Check this out!", and you want to add something like the name="name" sort of fields to it.
    In this part here:
    PHP Code:
    fputs($fp,"<GDFORM_VARIABLE NAME=$key START>\n");
    fputs($fp,"$val\n");
    fputs($fp,"<GDFORM_VARIABLE NAME=$key END>\n"); 
    You would be looking to add extra. From the looks of it, each variable corresponds to a value in the _GET/_POST superglobals.
    So, you could try something like:
    PHP Code:
    fputs($fp,"<GDFORM_VARIABLE NAME=$key START>\n");
    if (
    $key == 'subject'// Remember, it will only work if its written somewhere in the form!
    {
        
    fputs($fp$val ' ' $query_vars['name'] . "\n");
    }
    else
    {
        
    fputs($fp,"$val\n");
    }
    fputs($fp,"<GDFORM_VARIABLE NAME=$key END>\n"); 
    From the best I can see, you are submitting data to another file, and if this is used for the mailing it would be batched at some time later.
    Sorry I can't be of more help, but without the actual mailer script (and my lack of knowledge for this host), I can't give you much more.
    Hopefully, its something as simple as this!
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 

  • #3
    New to the CF scene
    Join Date
    Jan 2008
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    More help needed ~

    Thanks for the response.

    I tried:

    fputs($fp,"<GDFORM_VARIABLE NAME=$key START>\n");
    if ($key == 'subject') Order from: id="Editbox14"
    {
    fputs($fp, $val . ' ' . $query_vars['name'] . "\n");
    }
    else
    {
    fputs($fp,"$val\n");
    }
    fputs($fp,"<GDFORM_VARIABLE NAME=$key END>\n");


    I got:

    Parse error: parse error, unexpected T_STRING in /home/content/s/h/e/account/html/mywebsite.com/test/gdform.php on line 15


    I don't understand php syntax, or how to form the phrase - or what should go where "else" is.

    What would help is a complete phrasing suggestion I can play around with.



    In case you or someone else want to take another crack at it, let me clarify:

    a) The gdform.php - as it is - just puts all the form data into the email, and gets it sent.

    b) The subject line of the email comes from the html form post line - ie: the email subjects are all identical right now, "Order Information". If I change that html line, the email subject changes.

    c) I want the subject to read something like "Order from: (customer name info from form field "Editbox2")" ie: I just want it to grab the form field content and stick it in the subject line after "Order From"

    the html form field line I'm trying to pull content from is:

    <input type="text" id="Editbox14" style="position:absolute;left:480px;top:220px;width:287px;font-family:Franklin Gothic Book;font-size:16px;z-index:64" size="41" name="01_Name" value="" tabindex="Name">

    d) I know a fair amount of html, but I'm clueless about php.

    e) I'm not sure if what I'm looking for should go in the php, the html, or both.



    Thanks again all for any assistance.

  • #4
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,987
    Thanks
    4
    Thanked 2,660 Times in 2,629 Posts
    Ok.
    <input type="text" id="Editbox14" style="position:absolute;left:480px;top:220px;width:287px;font-family:Franklin Gothic Book;font-size:16px;z-index:64" size="41" name="01_Name" value="" tabindex="Name">

    Let see, you really should use a more straight forward naming convention, but to each his own. Oh, TabIndex is an integer value though, not a string value: tabindex=12 for example.

    The only things you really need are the key for the orderform subject, and the name you are looking for. Once you have those, you are set.
    As well, if the code you posted is exactly as it is, then this is the problem:
    f ($key == 'subject') Order from: id="Editbox14"
    Not sure exactly what that is supposed to do, but PHP cannot be processed anywhere near similar to JS. Here's what you should end up with:
    PHP Code:
    /* I will assume that the names are as follows: subject, and name.  They would appear like so in html:
    <input type="text" id="subject" name="subject" value="" />
    <input type="text" id="name" name="name" value="" /> //err, does name="name" work, I'm not sure may need to try that later :P
    */
    fputs($fp,"<GDFORM_VARIABLE NAME=$key START>\n");
    if (
    $key == 'subject'
    {
        
    // Ok, we are in the subject block.  Add the 'name' to it:
        
    fputs($fp$val ' ' $query_vars['name'] . "\n"); // This 'name' is the same as the HTML input element name for the name.
    }
    else
    {
        
    fputs($fp,"$val\n");
    }
    fputs($fp,"<GDFORM_VARIABLE NAME=$key END>\n"); 
    Thats about all I can do for you without the actual mailing script. You don't happen to er... have the script that does the actual mailing do you?
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •