Helpful Information
 
 
Category: PHP 5.04
PHP 5.04 > Email form delivers mail but without comment

Hi all, I need help with configuring my server with PHP.

I run Apache 1.3 and PHP 5.04 on an Apple G4 PowerMac with Panther 10.39. I've installed PHP from Entropy (http://www.entropy.ch/software/macosx/php/#install). I have also installed PostfixEnabler from Cutedgesystems (http://www.cutedgesystems.com/software/PostfixEnabler/).

All works fine except sending email. I use a form on my page to send the mail and it actually sends it out and I can retrieve it, but certain fields don't arrive. The comments are missing and the phone field is empty!

The PHP setup on my Mac is this (http://tinyurl.com/bbwhu).

I tried with register_globals = On (I think it does not matter if it's written ON, on, or On) in the master php.ini file. I have tried also to override the default OFF setting with a local php.ini file next to my formmail.php file where I set register_globals = On (thinking that this overrides the default OFF settings).

Since changing those settings did not do any good I believe that the solution to my problem might be somewhere else.

I use the same code (php and html) also on the pages at my regular hosting company (Catalog.com) where they run PHP 4.3.11 and all works fine there (however they have set register_globals to ON). My php setup with them can be seen here (http://tinyurl.com/9ycwf).

The email form which I use goes like this:


<?php

function email_injection_filter($formInput)
{
$injectionStrings = array("apparently-to",
"bcc",
"boundary=",
"charset",
"content-disposition",
"content-type",
"content-transfer-encoding",
"errors-to",
"in-reply-to",
"message-id",
"mime-version",
"multipart/mixed",
"multipart/alternative",
"multipart/related",
"reply-to",
"x-mailer",
"x-sender",
"x-uidl"
);
foreach ($injectionStrings as $spam)
{
$pos = strpos(strtolower($formInput), $spam);
if ($pos !== false)
{
error_log("Email injection attempt - From IP: " . $_SERVER['REMOTE_ADDR'] . " | Server Time: " . date('m\/d\/y, h:i:s A'), 1, "[email protected]");
exit("<html><title>Fatal Error</title><body><p>Sorry, your message could not be processed due to a fatal error.</p><p>Please contact us by telephone.</p></body></html>");
}
}
}

$sendto="[email protected]";
$emailsubject="[Website] Order of Prints";
$thankyou="thanks.html";
$msg = 'Tel: ' . $visitorPhone . "\r\n" . stripslashes($comments);
$from = "From: ".$_POST['visitorName']." <".$_POST['visitorEmail'].">\r\n";

if ($_POST['submit_x']) {

foreach ($_POST as $formInput)
{
email_injection_filter($formInput);
}

mail($sendto, $emailsubject, $msg, $from);
header("Location: $thankyou");
}
?>


When submitting a message on the page that is hosted at Catalog.com (PHP 4.3.11) all arrives, including the submitted phone number and the comment. The page is here (http://tinyurl.com/cfu66).

When submitting a message on the page with identical code as it is hosted on my own Mac (PHP 5.04) the submitted phone number and the submmitted comment do not arrive. I get however the prompted text element "Tel:" in the body, as well as the sender's email address! The page on my Mac is here (http://tinyurl.com/a8vwk).

Is there anything I have to still configure on my 5.04 PHP setup?

Thanks in advance,

Martin

$visitorPhone

should be

$_POST[$visitorPhone']

etc , then register_globals settings are irrelevant

Thanks Firepages - this works super :)

The old code:
$msg = 'Tel: ' . $visitorPhone . "\r\n" . stripslashes($comments); The new code:
$msg = 'Tel: ' . $_POST['visitorPhone'] . "\r\n" . stripslashes($_POST['comments']);

martin