I'm a newbie for sure. I've been searching the internet and books I have for a solution to the following error message.
Warning: Cannot modify header information - headers already sent by (output started at /home/keenancomm/www/www/test/ccc/aboutus/contact.php:1) in /home/keenancomm/www/www/test/ccc/aboutus/contact.php on line 59
I'm told it's probably a space or extra line or an echo or print statement or any html. But I just don't see it. Here's the first 60 lines of code.
Any help for a confused and frustrate newbie is much appreciated.
<?php if (@$_POST['submitted']) {
$name = @$_POST['name'];
$phone = @$_POST['phone'];
$email = @$_POST['email'];
$msg = @$_POST['message'];
// if magic quotes on, remove Magic Quotes effect
if ( get_magic_quotes_gpc() ) { // no arg needed - returns 1 if magic quotes are on, else 0
$name = stripslashes($name);
$phone = stripslashes($phone);
$email = stripslashes($email);
$msg = stripslashes($msg);
}
$error_msg=array(); // intialize array
if ($name=="") { // test for empty text string
$error_msg[]="Please enter your name";
}
if ($phone=="") { // test for empty text string
$error_msg[]="Please enter your phone"; // add to the array
}
if ($email=="") { // test for empty text string
$error_msg[]="Please enter your email address"; // add to the array
}
if ($msg=="") { // test for empty text string
$error_msg[]="Don't forget to write your message!"; // add to the array
}
// set up variables for use in the mail function 5
$destination_email="takeenan@gmail.com";
$email_subject="My PHP form info";
$headers="From: tom.keenan@earthlink.net";
$sentname="A message from $name";
$sentphone="Phone is $phone";
$sentmsg="Message : $msg";
$sentemail="email address: $email";
//assemble the email body text in a variable
$email_body = "$sentname\n\n$sentphone\n\n$sentmsg\n\n$sentemail";
// if no errors, and we are here b/c the form was submitted rather than the page first loading
if (!$error_msg) {
// then send the email using PHP's mail function
mail ($destination_email, $email_subject, $email_body, $headers);
// redirect to a new page - we are done on this page
header ('Location: form_confirm.php');
// stop the script right here
exit();
}