Php Form Mail Processing Script

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
pagemaker
Forum Newbie
Posts: 1
Joined: Fri Dec 18, 2009 11:19 am

Php Form Mail Processing Script

Post by pagemaker »

Hi Everyone I need some help here if possible.

I am currently using simplescript.php to process my form mail. it works well, but here is my problem when a customer fills out the form and submits it to me, I get all the information I asked for but the out put is all over the place on the page. The questions I asked are nice and even on the left side of the page all in order one question under the other. But the answers to the questions the customer provides are not. The answers are on the correct line but one answer will be on the left side of the page the next on the right side of the page and yet another in the middle of the page. Is there a way that I can get the information placed neatly on the page one under the other just like the questions are. Here is a copy of the script I am using.

Code: Select all

<?php
 
 
//--------------------------Set these paramaters--------------------------
 
 
$subject = 'New Homestay Application';                // Subject of email sent to you.
$emailadd = 'homestay@mydomain.com';        // Your email address. This is where the form information will be sent.
$url = 'http://www.mydomain.com/forms/thankyou.html';               // Where to redirect after form is processed.
$req = '0';                                  // Makes all fields required. If set to '1' no field can not be empty. If set to '0' any or all fields can be empty.
 
// --------------------------Do not edit below this line--------------------------
$text = "Results from Application form:\n\n";       
$space = '  ';
$line = '
';
foreach ($_POST as $key => $value)
{
    if ($req == '1')
    {
        if ($value == '')
        {echo "$key is empty";die;}
    }
    $j = strlen($key);
        if ($j >= 20)
        
    $j = 20 - $j;
        for ($i = 1; $i <= $j; $i++)
        {$space .= ' ';}
    $value = str_replace('\n', "$line", $value);
    $conc = "{$key}:$space{$value}$line";
    $text .= $conc;
    $space = '  ';
}
mail($emailadd, $subject, $text, 'From: '.$emailadd.'');
echo '<META HTTP-EQUIV=Refresh CONTENT="0; URL='.$url.'">';
?>
This is a copy of the out put from the simplescript.php
Results from Application form:
 
subject:         The DEWBERRY HOMESTAY Application
realname:          Larry Snow
email:       myemail@shaw.ca
Telephone:           790-765-7999
Fax:     790-765-7999
Gender:        Male
Age:     57
Guest_Address:               12222 - 87th. Avenue N.W.
City:      Edmonton
Province_State:                Alberta
Postal_Zip:            T8H 4H1
Country:         Canada
Check_in_Month:                January
Check_in_Day:              01
Check_in_Year:               2010
Check_Out_Month:                 November
Check_Out_Day:               31
Check_Out_Year:                2010
Student_Visa:              No
Work_Visa:           Yes
Health_Insurance:                  Yes
Room_Selection:                Room 3 Option 1 Monthly Fee $803.00 (USD) or $850.00 (CDN) Meals Included
Airport_Pickup:                Yes $25.00
Name_of_Airline:                 Air Canada
Flight_Number:               521
Arrival_Time:              2:45 pm
Arrival_Month:               January
Arrival_Day:             01
Arrival_Year:              2010
Emergency_Contact:                   Diana Snow
Relationship:              Wife
Language:          English
contactemail:              myemail@shaw.ca
Contact_Phone:               same
Contact_Address:                 same
Contact_City:              same
Contact_P/S:             same
Contact_Postal_Zip:                    same
Contact_Country:                 same
Allergies_Dietary:                   None at this time.
Comments:          Please let me know as soo as you can Thanks.
 
Submit:        Send Application Request
This is what I would like it to do or something along this line:
 
Results from Application form:
 
subject:                           The DEWBERRY HOMESTAY Application
realname:                          Larry Snow
email:                               myemail@shaw.ca
Telephone:                        790-765-7999
Fax:                                 790-765-7999
Gender:                             Male
Age:                                 57
Guest_Address:                  12222 - 87th. Avenue N.W.
City:                                 Edmonton
Province_State:                  Alberta
Postal_Zip:                        T8H 4H1
Country:                            Canada
Check_in_Month:                January
Check_in_Day:                    01
Check_in_Year:                   2010
Check_Out_Month:              November
Check_Out_Day:                 31
Check_Out_Year:                2010
Student_Visa:                    No
Work_Visa:                        Yes
Health_Insurance:               Yes
Room_Selection:                 Room 3 Option 1 Monthly Fee $803.00 (USD) or $850.00 (CDN) Meals Included
Airport_Pickup:                   Yes $25.00
Name_of_Airline:                 Air Canada
Flight_Number:                   521
Arrival_Time:                      2:45 pm
Arrival_Month:                    January
Arrival_Day:                       01
Arrival_Year:                      2010
Emergency_Contact:           Diana Snow
Relationship:                      Wife
Language:                         English
contactemail:                     myemail@shaw.ca
Contact_Phone:                  same
Contact_Address:                same
Contact_City:                     same
Contact_P/S:                      same
Contact_Postal_Zip:             same
Contact_Country:                same
Allergies_Dietary:                 None at this time.
Comments:                         Please let me know as soo as you can Thanks.
 
Submit:        Send Application Request
 
I hope that some will have the answer to this so I can organize my form output. Many thanks in advance for any help you can provide me.
Post Reply