mbsmi
02-18-2012, 04:31 AM
I am having an issue when I click submit on my html/php form. When I click submit (with nothing filled in), I get:
Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/content/05/6544605/html/w2/mailform.php:2) in /home/content/05/6544605/html/w2/mailform.php on line 33
Sorry, you failed the CAPTCHA. Note that the CAPTCHA is case-sensitive. Please hit your browser back button and try again.
I understand the last part, but the first part is what I don't get. Below is the code, with a comment at line 33.
If I fill in the form, it goes back to my index.php page, but it shows the line below.
Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/content/05/6544605/html/w2/mailform.php:2) in /home/content/05/6544605/html/w2/mailform.php on line 33
Here is my mailform.php file below, with a comment at line 33.
<?php
$dontsendemail = 0;
$possiblespam = FALSE;
$strlenmessage = "";
$email = $_REQUEST['email'];
$message_start = $_REQUEST['message'];
$message_start2 = $_REQUEST['fname'];
$message = "From: $message_start2 \n Message: $message_start";
$subject = array();
$subject[1] = "General";
$subject[2] = "Project";
$subject[3] = "Website";
$subjectindex = $_REQUEST['subject'];
if ($subjectindex == 0 || !isset($_REQUEST['subject'])) die ("You did not choose a subject line. Please hit your browser back button and try again.");
else $subject = $subject[$subjectindex];
$emailaddress = array(); /* NOTE: Although your email addresses
are visible here in this code, the person contacting you will never see these email addresses.
Your email addresses will remain on your server, and they will not be sent from your server
to the person contacting you. They will also remain invisible to spam bots. Your email addresses
are also never stored on any of our servers. You can choose to delete or not delete this note
when you publish this page. It will not change the functionality of the contact form.
*/
$emailaddress[1] = "michael@rroutpost1.org";
$emailaddress[2] = "michael@accessdrive.net";
$contactnameindex = $_REQUEST['emailaddress'];
if ($contactnameindex == 0 || !isset($_REQUEST['emailaddress'])) die ("You did not choose a recipient. Please hit your browser back button and try again.");
else $emailaddress = $emailaddress[$contactnameindex];
function checkcaptcha() {
<!-- Line 33 --> session_start();
if ($_SESSION["pass"] != $_POST["userpass"]) {
die("Sorry, you failed the CAPTCHA. Note that the CAPTCHA is case-sensitive. Please hit your browser back button and try again.");
return 1;
}
}
function checkemail($field) {
// checks proper syntax
if( !preg_match( "/^([a-zA-Z0-9])+([a-zA-Z0-9._-])*@([a-zA-Z0-9_-])+([a-zA-Z0-9._-]+)+$/", $field))
{
die("Improper email address detected. Please hit your browser back button and try again.");
return 1;
}
}
function spamcheck($field) {
if(eregi("to:",$field) || eregi("cc:",$field) || eregi("\r",$field) || eregi("\n",$field) || eregi("%0A",$field)){
$possiblespam = TRUE;
}else $possiblespam = FALSE;
if ($possiblespam) {
die("Possible spam attempt detected. If this is not the case, please edit the content of the contact form and try again.");
return 1;
}
}
function strlencheck($field,$minlength,$whichfieldresponse) {
if (strlen($field) < $minlength){
die($whichfieldresponse);
return 1;
}
}
if ($dontsendemail == 0) $dontsendemail = checkcaptcha($email);
if ($dontsendemail == 0) $dontsendemail = checkemail($email);
if ($dontsendemail == 0) $dontsendemail = spamcheck($email);
if ($dontsendemail == 0) $dontsendemail = spamcheck($subject);
if ($dontsendemail == 0) $dontsendemail = strlencheck($email,10,"The email address field is too short. Please hit your browser back button and check your entry.<br />");
if ($dontsendemail == 0) $dontsendemail = strlencheck($subject,1,"You did not choose a subject. Please hit your browser back button and check your entry.<br />");
if ($dontsendemail == 0) $dontsendemail = strlencheck($message,10,"The message field is too short. Please hit your browser back button and check your entry.<br />");
if ($dontsendemail == 0) $dontsendemail = strlencheck($emailaddress,8,"You have not selected a recipient of your message. Please hit your browser back button and check your entry.<br />");
if ($dontsendemail == 0) {mail($emailaddress,"Subject: $subject",$message,"From: $email" ); include "index.php";}
?>
Any help would be greatly appreciated.
Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/content/05/6544605/html/w2/mailform.php:2) in /home/content/05/6544605/html/w2/mailform.php on line 33
Sorry, you failed the CAPTCHA. Note that the CAPTCHA is case-sensitive. Please hit your browser back button and try again.
I understand the last part, but the first part is what I don't get. Below is the code, with a comment at line 33.
If I fill in the form, it goes back to my index.php page, but it shows the line below.
Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/content/05/6544605/html/w2/mailform.php:2) in /home/content/05/6544605/html/w2/mailform.php on line 33
Here is my mailform.php file below, with a comment at line 33.
<?php
$dontsendemail = 0;
$possiblespam = FALSE;
$strlenmessage = "";
$email = $_REQUEST['email'];
$message_start = $_REQUEST['message'];
$message_start2 = $_REQUEST['fname'];
$message = "From: $message_start2 \n Message: $message_start";
$subject = array();
$subject[1] = "General";
$subject[2] = "Project";
$subject[3] = "Website";
$subjectindex = $_REQUEST['subject'];
if ($subjectindex == 0 || !isset($_REQUEST['subject'])) die ("You did not choose a subject line. Please hit your browser back button and try again.");
else $subject = $subject[$subjectindex];
$emailaddress = array(); /* NOTE: Although your email addresses
are visible here in this code, the person contacting you will never see these email addresses.
Your email addresses will remain on your server, and they will not be sent from your server
to the person contacting you. They will also remain invisible to spam bots. Your email addresses
are also never stored on any of our servers. You can choose to delete or not delete this note
when you publish this page. It will not change the functionality of the contact form.
*/
$emailaddress[1] = "michael@rroutpost1.org";
$emailaddress[2] = "michael@accessdrive.net";
$contactnameindex = $_REQUEST['emailaddress'];
if ($contactnameindex == 0 || !isset($_REQUEST['emailaddress'])) die ("You did not choose a recipient. Please hit your browser back button and try again.");
else $emailaddress = $emailaddress[$contactnameindex];
function checkcaptcha() {
<!-- Line 33 --> session_start();
if ($_SESSION["pass"] != $_POST["userpass"]) {
die("Sorry, you failed the CAPTCHA. Note that the CAPTCHA is case-sensitive. Please hit your browser back button and try again.");
return 1;
}
}
function checkemail($field) {
// checks proper syntax
if( !preg_match( "/^([a-zA-Z0-9])+([a-zA-Z0-9._-])*@([a-zA-Z0-9_-])+([a-zA-Z0-9._-]+)+$/", $field))
{
die("Improper email address detected. Please hit your browser back button and try again.");
return 1;
}
}
function spamcheck($field) {
if(eregi("to:",$field) || eregi("cc:",$field) || eregi("\r",$field) || eregi("\n",$field) || eregi("%0A",$field)){
$possiblespam = TRUE;
}else $possiblespam = FALSE;
if ($possiblespam) {
die("Possible spam attempt detected. If this is not the case, please edit the content of the contact form and try again.");
return 1;
}
}
function strlencheck($field,$minlength,$whichfieldresponse) {
if (strlen($field) < $minlength){
die($whichfieldresponse);
return 1;
}
}
if ($dontsendemail == 0) $dontsendemail = checkcaptcha($email);
if ($dontsendemail == 0) $dontsendemail = checkemail($email);
if ($dontsendemail == 0) $dontsendemail = spamcheck($email);
if ($dontsendemail == 0) $dontsendemail = spamcheck($subject);
if ($dontsendemail == 0) $dontsendemail = strlencheck($email,10,"The email address field is too short. Please hit your browser back button and check your entry.<br />");
if ($dontsendemail == 0) $dontsendemail = strlencheck($subject,1,"You did not choose a subject. Please hit your browser back button and check your entry.<br />");
if ($dontsendemail == 0) $dontsendemail = strlencheck($message,10,"The message field is too short. Please hit your browser back button and check your entry.<br />");
if ($dontsendemail == 0) $dontsendemail = strlencheck($emailaddress,8,"You have not selected a recipient of your message. Please hit your browser back button and check your entry.<br />");
if ($dontsendemail == 0) {mail($emailaddress,"Subject: $subject",$message,"From: $email" ); include "index.php";}
?>
Any help would be greatly appreciated.