I just switched hosting companies and opted for PHP5 on the new server. The field "Home_Owner's_Name" is not passing through the email form, but all other lines are working fine. Any help is appreciated.

<?php
if ($_SERVER['REQUEST_METHOD'] == "POST")
{
    // store the file information to variables for easier access
    $tmp_name = $_FILES['userfile']['tmp_name'];
    $name = $_FILES['userfile']['name'];
    $size = $_FILES['userfile']['size'];

echo "<html>";
echo "<body>";


$subject = " Order Placed ";

$from = $_POST['email'];
$user_email = $_POST['email'];

//  a text messge
$message = "<html> <body>";
$message .= "<h3>Order Form</h3>.<hr width=75% align=left height=2 color=green><br>";
if ($_POST["Home_Owner's_Name"])
{
    $message .= "Home Owner's Name:  " . $_POST["Home_Owner's_Name"] . "<br>";
}
if ($_POST["Project_Street_Address"])
{
    $message .= "Project Street Address:  " . $_POST["Project_Street_Address"] .
        "<br>";
}
if ($_POST["Project_City,_State,_Zip"])
{
    $message .= "Project City, State, Zip:  " . $_POST["Project_City,_State,_Zip"] .
        "<br>";
}
if ($_POST["designer_name"])
{
    $message .= "Designer Name:  " . $_POST["designer_name"] . "<br>";
}
if ($_POST["designer_address"])
{
    $message .= "Designer Address:  " . $_POST["designer_address"] . "<br>";
}
if ($_POST["designer_city"])
{
    $message .= "Designer City:  " . $_POST["designer_city"] . "<br>";
}
if ($_POST["Contact_Phone"])
{
    $message .= "Contact Phone:  " . $_POST["Contact_Phone"] . "<br>";
}
if ($_POST["email"])
{
    $message .= "E-mail:  " . $_POST["email"] . "<br>";
}
if ($_POST["year_built"])
{
    $message .= "Year built:  " . $_POST["year_built"] . "<br>";
}
if ($_POST["floors"])
{
    $message .= "Floors:  " . $_POST["floors"] . "<br>";
}
if ($_POST["existing_square_footage"])
{
    $message .= "Existing Square footage:  " . $_POST["existing_square_footage"] .
        "<br>";
}
if ($_POST["Total_Existing_Square_Footage"])
{
    $message .= "Total Existing Square Footage:  " . $_POST[
        "Total_Existing_Square_Footage"] . "<br>";
}
if ($_POST["North"])
{
    $message .= "Bottom of Floor Plan Page is:  " . $_POST["North"] . "<br>";
}
if ($_POST["Wall_Framed"])
{
    $message .= "Wall Framed: " . $_POST["Wall_Framed"] . "<br>";
}
if ($_POST["ceiling"])
{
    $message .= "Ceiling:  " . $_POST["ceiling"] . "<br>";
}
if ($_POST["exist_window_type"])
{
    $message .= "Existing Window Type:  " . $_POST["exist_window_type"] . "<br>";
}
if ($_POST["exist_window_material"])
{
    $message .= "Existing Window Material:  " . $_POST["exist_window_material"] .
        "<br>";
}
if ($_POST["Foundation_Type"])
{
    $message .= "Foundation Type:  " . $_POST["Foundation_Type"] . "<br>";
}
if ($_POST["Skylites"])
{
    $message .= "Skylites:  " . $_POST["Skylites"] . "<br>";
}
if ($_POST["Existing_Heating_System"])
{
    $message .= "Existing Heating System:  " . $_POST["Existing_Heating_System"] .
        "<br>";
}
if ($_POST["Existing_Water_Heater_Type"])
{
    $message .= "Existing Water Heater Type:  " . $_POST[
        "Existing_Water_Heater_Type"] . "<br>";
}
if ($_POST["Adding_Water_Heater"])
{
    $message .= "Adding Water Heater: " . $_POST["Adding_Water_Heater"] . "<br>";
}
if ($_POST["Existing_Water_Heater_Size"])
{
    $message .= "Existing Water Heater Size:  " . $_POST[
        "Existing_Water_Heater_Size"] . "<br>";
}
if ($_POST["New_Water_Heater_Size"])
{
    $message .= "New Water Heater Size:  " . $_POST["New_Water_Heater_Size"] .
        "<br>";
}
if ($_POST["Air_Conditioning"])
{
    $message .= "Air Conditioning:  " . $_POST["Air_Conditioning"] . "<br>";
}
if ($_POST["Addition_Sq_Ft:"])
{
    $message .= "Addition Sq Ft:  " . $_POST["Addition_Sq_Ft:"] . "<br>";
}
if ($_POST["square_footage_for_each floor"])
{
    $message .= "Square Footage For Eeach Floor:  " . $_POST[
        "square_footage_for_each floor"] . "<br>";
}
if ($_POST["AC/Heat_Service_Addtion?"])
{
    $message .= "AC/Heat Service Addtion:  " . $_POST["AC/Heat_Service_Addtion?"] .
        "<br>";
}
if ($_POST["Window_Material_Desired"])
{
    $message .= "Window Material Desired::  " . $_POST["Window_Material_Desired"] .
        "<br>";
}
if ($_POST["comments"])
{
    $message .= "comments:  " . $_POST["comments"] . "<br>";
}

require ("class.phpmailer.php");

$mail = new PHPMailer();

$mail->From = $from;
$mail->FromName = $from;
$mail->AddAddress($to);

$mail->Subject = $subject;

$mail->Body = $message;

// check to make sure that it is an uploaded file and not a system file
if (is_uploaded_file($tmp_name))
{
    $mail->AddAttachment($tmp_name, $name);
}
// now we just send the message after spam filtration.
    if ($mail->Send())
    {
        echo "Your Order form has been sent. ";
		// autoresponder mail code starts here
		$mail1 = new PHPMailer();






    }
    else
print "</body>";
print "</html>";
}
else
{
?>

Added [noparse]

...

[/noparse] tags around code -- NogDog[/color][/i]

    The problem is probably the "'" in the field name. I would recommend changing it to something without the quote; but if you really need it, then you'll have to escape it in the code, e.g. $_POST["Home_Owner\'s_Name"].

      No ... the apostrophes would be fine, as is the comma and colon (one of the fields has the colon as part of the name, the others don't: why is this?) ... odd, but legitimate. Then again, spaces would be legitimate as well and PHP translates them to underscores.

      I'm not having problems with apostrophes in my tests; what else does $_REQUEST contain, and what does the form itself look like?

        Weedpacket;10889494 wrote:

        No ... the apostrophes would be fine, as is the comma and colon (one of the fields has the colon as part of the name, the others don't: why is this?) ... odd, but legitimate. Then again, spaces would be legitimate as well and PHP translates them to underscores.

        I'm not having problems with apostrophes in my tests; what else does $REQUEST contain, and what does the form itself look like?


        Here's my test and results:

        <form action="" method="post">
           <input type="hidden" name="This_here's_a_test" value="test">
           <input type="submit">
        </form>
        <pre><?php
        print_r($_POST);
        echo $_POST['This_here\\\'s_a_test'] . "\n";
        echo $_POST["This_here\\'s_a_test"] . "\n";
        echo $_POST['This_here\'s_a_test'] . "\n";
        echo $_POST["This_here's_a_test"] . "\n";
        ?></pre>
        

        Output:

        Array
        (
            [This_here\'s_a_test] => test
        )
        test
        test
        
        Notice:  Undefined index:  This_here's_a_test in C:\wamp\www\test\test.php on line 9
        
        Notice:  Undefined index:  This_here's_a_test in C:\wamp\www\test\test.php on line 10
        

        PHP 5.2.6 on WinVista under Apache 2.2.8 tested in Firefox 3.0.3

        Verdict: somewhere in the process between form submission and the start of executing the PHP commands in my script, a backslash is insinuated into the $_POST array element key for that field.

          My output (less XDebug markup):

          Array
          (
              [This_here's_a_test] => test
          )
          
          
          Notice: Undefined index: This_here\'s_a_test in C:\Apache\htdocs\test.php on line 7
          
          Notice: Undefined index: This_here\'s_a_test in C:\Apache\htdocs\test.php on line 8
          
          
          test
          test
          

          PHP 5.2.6 Windows XP, Apache 2.0.49, Firefox 3.0.3.

          Are you sure you haven't got magic_quotes_gpc turned on? 🙂 I guess that's what I'd be looking at next.

            Weedpacket;10889555 wrote:

            ...

            Are you sure you haven't got magic_quotes_gpc turned on? 🙂 I guess that's what I'd be looking at next.

            Doh! I had checked that by taking a quick look at my php.ini to make sure it was off. However, I forgot I'd turned it on in a .htaccess file in my test directory to check something out last week and never got rid of it. :o :eek:

            Anyway, long story short for the OP, check your magic_quotes_gpc setting. 😉

              Write a Reply...