Solved

Order the email results from a form

Posted on 2008-10-31
7
163 Views
Last Modified: 2012-05-05
I am currently getting the results of the form in the following order (alphabetical):
AdditionalInfo:
Commodity:
CompanyName:
ContactEmail:
ContactName:
DestinationZipCode:
FaxNumber:
FreightClass:
OriginZipCode:
PhoneNumber:
Pieces:
freightClassH:
freightClassL:
freightClassW:
hazmat:

I want it to be an easier to read output like the following:
CompanyName:
ContactName:
ContactEmail:
PhoneNumber:
FaxNumber:
etc.

What do I need to change in my code to accomplish that?
<form action="/gdform.php" method="post" name="ltlForm" id="ltlForm">

                  <input type="hidden" name="redirect" value="test/thanks.htm"> 
 
 

                    <table width="100%" border="0" cellspacing="2" cellpadding="0">

                      <tr>

                        <td width="34%" align="left" valign="top" class="K_10pt">Company Name *</td>

                        <td colspan="2" align="left" valign="top"><label>

                          <input name="CompanyName" type="text" class="K_10pt" id="CompanyName" size="50" />

                        </label></td>

                      </tr>

                      <tr>

                        <td align="left" valign="top" class="K_10pt">Contact Name *</td>

                        <td colspan="2" align="left" valign="top"><input name="ContactName" type="text" class="K_10pt" id="ContactName" size="50" /></td>

                      </tr>

                      <tr>

                        <td align="left" valign="top" class="K_10pt">Contact Email Address * </td>

                        <td colspan="2" align="left" valign="top"><input name="ContactEmail" type="text" class="K_10pt" id="ContactEmail" size="50" /></td>

                      </tr>

                      <tr>

                        <td align="left" valign="top" class="K_10pt">Phone Number</td>

                        <td colspan="2" align="left" valign="top"><input name="PhoneNumber" type="text" class="K_10pt" id="PhoneNumber" size="50" /></td>

                      </tr>

                      <tr>

                        <td align="left" valign="top" class="K_10pt">Fax Number</td>

                        <td colspan="2" align="left" valign="top"><input name="FaxNumber" type="text" class="K_10pt" id="FaxNumber" size="50" /></td>

                      </tr>

                      <tr>

                        <td align="left" valign="top" class="K_10pt">Origin Zip Code *</td>

                        <td colspan="2" align="left" valign="top"><input name="OriginZipCode" type="text" class="K_10pt" id="OriginZipCode" size="50" /></td>

                      </tr>

                      <tr>

                        <td align="left" valign="top" class="K_10pt">Destination Zip Code *</td>

                        <td colspan="2" align="left" valign="top"><input name="DestinationZipCode" type="text" class="K_10pt" id="DestinationZipCode" size="50" /></td>

                      </tr>

                      <tr>

                        <td align="left" valign="top" class="K_10pt">Commodity *</td>

                        <td colspan="2" align="left" valign="top"><input name="Commodity" type="text" class="K_10pt" id="Commodity" size="50" /></td>

                      </tr>

                      <tr>

                        <td align="left" valign="top" class="K_10pt">Hazmat * </td>

                        <td colspan="2" align="left" valign="top" class="K_10pt">Yes:

                          <label>

                          <input type="radio" name="hazmat" id="hazmat" value="Yes" />

                          No:

                          

                          <input name="hazmat" type="radio" id="hazmat" value="No" checked="checked" />

</label></td>

                      </tr>

                      <tr>

                        <td rowspan="4" align="left" valign="top" class="K_10pt">Freight Class *</td>

                        <td colspan="2" align="left" valign="top" class="K_10pt"><input name="FreightClass" type="text" class="K_10pt" id="FreightClass" size="50" /></td>

                        </tr>

                      <tr>

                        <td width="7%" align="left" valign="top" class="K_10pt">L:                          </td>

                        <td width="59%" align="left" valign="top" class="K_10pt"><input name="freightClassL" type="text" class="K_10pt" id="freightClassL" size="15" /></td>

                      </tr>

                      <tr>

                        <td align="left" valign="top" class="K_10pt">W:                          </td>

                        <td align="left" valign="top" class="K_10pt"><input name="freightClassW" type="text" class="K_10pt" id="freightClassW" size="15" /></td>

                      </tr>

                      <tr>

                        <td align="left" valign="top" class="K_10pt">H:                          </td>

                        <td align="left" valign="top" class="K_10pt"><input name="freightClassH" type="text" class="K_10pt" id="freightClassH" size="15" /></td>

                      </tr>

                      <tr>

                        <td align="left" valign="top" class="K_10pt">Pieces *</td>

                        <td colspan="2" align="left" valign="top"><input name="Pieces" type="text" class="K_10pt" id="Pieces" size="50" /></td>

                      </tr>

                      <tr>

                        <td align="left" valign="top" class="K_10pt">Additional Information</td>

                        <td colspan="2" align="left" valign="top"><textarea name="AdditionalInfo" cols="50" rows="4" class="K_10pt" id="AdditionalInfo"></textarea></td>

                      </tr>

                      <tr>

                        <td class="K_10pt">&nbsp;</td>

                        <td colspan="2">&nbsp;</td>

                      </tr>

                      <tr>

                        <td class="K_10pt">&nbsp;</td>

                        <td colspan="2"><label>

                          <input type="reset" name="reset" id="reset" value="Reset" />

                          <input type="submit" value="Submit Quote Request" />

                        </label></td>

                      </tr>

                      <tr>

                        <td class="K_10pt">&nbsp;</td>

                        <td colspan="2">&nbsp;</td>

                      </tr>

                    </table>

                                                      </form>

Open in new window

0
Comment
Question by:msukow
  • 5
  • 2
7 Comments
 
LVL 54

Expert Comment

by:b0lsc0tt
ID: 22855532
msukow,

The change needs to be made in the PHP file.  The file that gets the form info and sends the email.

Let me know if you have any questions or need more information.

b0lsc0tt
0
 
LVL 54

Expert Comment

by:b0lsc0tt
ID: 22855533
msukow,

Please show us that code if you need details on what to change or how.

b0lsc0tt
0
 

Author Comment

by:msukow
ID: 22856315
I have attached the code snippet - I do not know what needs to be adjusted.
<?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"]."/");

    }
 
 

?>

Open in new window

0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 54

Accepted Solution

by:
b0lsc0tt earned 500 total points
ID: 22859967
Thanks for the PHP code.  The method to use if you want the info in the file to be in a specific order is to not use the "get/post array" (i.e. $query_vars) but get each value using $_POST or $_GET.  For example $_POST['CompanyName'].  If you want to use the While loop to write the info in the file then create an array of the field names in the order you want and go through that array.  If you need help with using this method then let me know what part of how you want to use it.  This would make it so the data in the file would be in the order you want because you write it in the order, instead of relying on the order of the get/post vars array.
bol
0
 

Author Comment

by:msukow
ID: 22885768
Actually, I changed the names of the fields so that a number was in front of them. That way it will be correctly ordered.
0
 
LVL 54

Expert Comment

by:b0lsc0tt
ID: 22886920
That would work too.  Let me know if you need any other help with this.
bol
0
 
LVL 54

Expert Comment

by:b0lsc0tt
ID: 22890636
I'm glad I could help with this.  Thanks for the grade, the points and the fun question.
bol
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Illegal invocation error when listener added to Event Target 3 28
Split in Javascript 5 31
Having problem getting this to work 2 21
how can i extend ? 2 22
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
This article discusses four methods for overlaying images in a container on a web page
In this tutorial viewers will learn how to style elements, such a divs, with a "drop shadow" effect using the CSS box-shadow property Start with a normal styled element, such as a div.: In the element's style, type the box shadow property: "box-shad…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now