Forum Moderators: coopster
I have a form processing script. It works on my own site, and another 2 sites, plus on a test site for the live site i'm having troubles with. The script works on both windows and linux servers.
The problem is on a windows server.
Notice: Undefined variable: message in **path to file** on line 132
Warning: Cannot modify header information - headers already sent by (output started at **path to file**:132) in **path to file** on line 147
The lines in question are -
lines 126 to 132 -
// Set ini command for windows server. change the email and domain according to the website
ini_set("sendmail_from", " info@example.com ");
// Set email, subject and style the email message
$to = "info@example.com";
$subject = "Web Brochure Request";
$headers = "From: " . $_POST['email'];
$message .= "You have recieved a request for a brochure to be sent out to the following\n"; ;
I cant see anything wrong, like i said, it works on the test site. (different server, but both on windows server).
Lines 146-147
if (mail($to,$subject,$message,$headers)) {
header('Location: requestsent.htm'); // success
Again, nothing wrong as far as i know, and it works on other servers/ftp accounts/websites.
Any ideas greatly appreciated
:)
edit - cant edit the title to add in something thats a bit more useful/helpful ;)
However, this notice is indicating that you have not initialised/defined your $message variable before you are appending to it (string concatenation .=).
$message .= "You have recieved a request for a brochure to be sent out to the following\n"; ;
PHP may well default to appending your string to an empty string, so it may still work, but it is not clear that this is meant to happen and in some cases it might not happen - hence the notice.
(You also have an additional ';' ?)
The following warning is a result of this notice being output. Headers cannot be sent once output has begun.