Dynamically changing a form

  • mindfullsilence
  • Professor
  • Professor
  • User avatar
  • Posts: 854

Post 3+ Months Ago

Hey guys, I'm using the gdform.php script provided by godadddy, it's their form mailer. Like most form mail scripts it grabs the name attribute of a field and displays that in the email as the title.
example email:
Quote:
Entity: Business
First: Timothy
Inquiry: Pricing
Last: Anderson

here's the script:
Code: [ Select ]
<?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'] . "\ssfm\gdform_" . $t;
    $fp = fopen($file,"w");
 
    while (list ($key, $val) = each ($query_vars))
    {
        fputs($fp,"<GDFORM_VARIABLE NAME=$key START>\r\n");
        fputs($fp,"$val\r\n");
        fputs($fp,"<GDFORM_VARIABLE NAME=$key END>\r\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"]."/");
    }
?>
  1. <?php
  2.     $request_method = $_SERVER["REQUEST_METHOD"];
  3.     if($request_method == "GET")
  4.     {
  5.         $query_vars = $_GET;
  6.     }
  7.     elseif ($request_method == "POST")
  8.     {
  9.         $query_vars = $_POST;
  10.     }
  11.  
  12.     reset($query_vars);
  13.     $t = date("U");
  14.     $file = $_SERVER['DOCUMENT_ROOT'] . "\ssfm\gdform_" . $t;
  15.     $fp = fopen($file,"w");
  16.  
  17.     while (list ($key, $val) = each ($query_vars))
  18.     {
  19.         fputs($fp,"<GDFORM_VARIABLE NAME=$key START>\r\n");
  20.         fputs($fp,"$val\r\n");
  21.         fputs($fp,"<GDFORM_VARIABLE NAME=$key END>\r\n");
  22.         if ($key == "redirect")
  23.         {
  24.             $landing_page = $val;
  25.         }
  26.     }
  27.  
  28.     fclose($fp);
  29.    
  30.     if ($landing_page != "")
  31.     {
  32.         header("Location: http://".$_SERVER["HTTP_HOST"]."/$landing_page");
  33.     }
  34.     else
  35.     {
  36.         header("Location: http://".$_SERVER["HTTP_HOST"]."/");
  37.     }
  38. ?>

The problem with this script is that it's proprietary to godaddy so I can't change any of it otherwise godaddy relays an error.
I have a couple question:
First off, it's changing the fields around before it sends out the email. Is there a way to control which order they go? I'd like them to be sent to the email in the order that my form is set up.
My form (abridged):
Code: [ Select ]
<form action="gdform.php" method="post" style="margin-left: 20px;" name="contactform">
<input type="hidden" name="subject" value="subject" id="contactform" />
<input type="hidden" name="redirect" value="thankyou.html" />
First Name:
<input type="text" name="First" />
Last Name:
<input type="text" name="Last" />
E-Mail:<input type="text" name="Email" />
Entity:
<input type="radio" name="Entity" value="Business" />Business<br />
<input type="radio" name="Entity" value="Residential" />Residential
Inquiry:
<select name="Inquiry" id="inquire">
<option>Service Area</option>
<option>Pricing</option>
<option>Promotions</option>
<option>Appointment</option>
<option>Other</option>
</select>
Comments:
<textarea name="Comments" cols="50" rows="7" onfocus="subjectChange();"></textarea>
<input type="submit" name="submit" value="submit" />
</form>
  1. <form action="gdform.php" method="post" style="margin-left: 20px;" name="contactform">
  2. <input type="hidden" name="subject" value="subject" id="contactform" />
  3. <input type="hidden" name="redirect" value="thankyou.html" />
  4. First Name:
  5. <input type="text" name="First" />
  6. Last Name:
  7. <input type="text" name="Last" />
  8. E-Mail:<input type="text" name="Email" />
  9. Entity:
  10. <input type="radio" name="Entity" value="Business" />Business<br />
  11. <input type="radio" name="Entity" value="Residential" />Residential
  12. Inquiry:
  13. <select name="Inquiry" id="inquire">
  14. <option>Service Area</option>
  15. <option>Pricing</option>
  16. <option>Promotions</option>
  17. <option>Appointment</option>
  18. <option>Other</option>
  19. </select>
  20. Comments:
  21. <textarea name="Comments" cols="50" rows="7" onfocus="subjectChange();"></textarea>
  22. <input type="submit" name="submit" value="submit" />
  23. </form>

also, if you notice in the comments field, I have an event handler that isn't working. I want to change the subject to whatever is selected in the inquiry drop-down list.
javascript code:
Code: [ Select ]
<!--
function subjectChange(){
    var initSubject = document.getElementById("contactform").value;
    var selectInquire = document.getElementById("inquire").selectedIndex;
    document.getElementById("contactform").value = selectInquire;
    return true;
 }
 // -->
  1. <!--
  2. function subjectChange(){
  3.     var initSubject = document.getElementById("contactform").value;
  4.     var selectInquire = document.getElementById("inquire").selectedIndex;
  5.     document.getElementById("contactform").value = selectInquire;
  6.     return true;
  7.  }
  8.  // -->


any ideas? Whenever I submit an email through this form the subject reads "subject" without the quotes of course. Point is it's not changing at all. I've tried calling this function with onsubmit placed in the form tag and on the button tag, as well as the onfocus in the Inquiry and comments fields.
I tried a few searches on the forum but couldn't find anything. I'm not too great at javascript so it's hard for me to interpret something as similar to my problem or not.
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • mindfullsilence
  • Professor
  • Professor
  • User avatar
  • Posts: 854

Post 3+ Months Ago

Really guys I'll be grateful to an answer to even one of the questions. If you can't answer the other it's all good, I'm sure I'll find it eventually. Any takers?

Post Information

  • Total Posts in this topic: 2 posts
  • Users browsing this forum: No registered users and 95 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.