php - Error 500: Premature end of script headers -
i "premature end of script headers: contactform.cgi" error message when running below script. frustrates me ran .php on server , worked. however, had change servers , support cgi php. however, doesn't work. don't think code wrong, take in case.
i've read around , have said it's permissions issue. case me?
i know "display_errors" , "error_reporting" statements display errors in error log, if don't have access server, how can check logs?
#!/usr/local/bin/php <?php print "content-type: text/html\n\n"; use cgi::carp qw(fatalstobrowser); ini_set('display_errors',1); error_reporting(e_all); if(isset($_post['email'])) { //email form me $email_to = "myemail@yahoo.com"; function died($error) { // error code can go here echo "oops... something's wrong. "; echo "fix error(s) below:<br /><br />"; echo $error."<br /><br />"; echo "all base belong us...<br /><br />"; die(); } // validation expected data exists if(!isset($_post['first_name']) || !isset($_post['last_name']) || !isset($_post['email']) || !isset($_post['subject']) || !isset($_post['comments'])) { died('there appears problem form submitted.'); } $first_name = $_post['first_name']; // required $last_name = $_post['last_name']; // required $email_from = $_post['email']; // required $subject = $_post['subject']; // not required $comments = $_post['comments']; // required $error_message = ""; $email_exp = '/^[a-za-z0-9._%-]+@[a-za-z0-9.-]+\.[a-za-z]{2,4}$/'; if(!preg_match($email_exp,$email_from)) { $error_message .= 'the email address entered not appear valid.<br />'; } $string_exp = "/^[a-za-z .'-]+$/"; if(!preg_match($string_exp,$first_name)) { $error_message .= 'the first name entered not appear valid.<br />'; } if(!preg_match($string_exp,$last_name)) { $error_message .= 'the last name entered not appear valid.<br />'; } if(strlen($comments) < 2) { $error_message .= 'the comments entered not appear valid.<br />'; } if(strlen($error_message) > 0) { died($error_message); } $email_message = "form details below.\n\n"; function clean_string($string) { $bad = array("content-type","bcc:","to:","cc:","href"); return str_replace($bad,"",$string); } $email_message .= "first name: ".clean_string($first_name)."\n"; $email_message .= "last name: ".clean_string($last_name)."\n"; $email_message .= "email: ".clean_string($email_from)."\n"; $email_message .= "subject: ".clean_string($subject)."\n"; $email_message .= "comments: ".clean_string($comments)."\n"; //email subject (put here include subject form) $email_subject = "cor | ".clean_string($subject).""; // create email headers $headers = 'from: '.$email_from."\r\n". 'reply-to: '.$email_from."\r\n" . 'x-mailer: php/' . phpversion(); @mail($email_to, $email_subject, $email_message, $headers); ?> <!-- include own success html here --> <?php header("location: cor/thankyou.html"); } ?>
i thought answer own question kicks , giggles (and might 1 day find same error , no answers).
it file permission issue.
all files on website set permission of '644.' once changed permission level 705 (chmod 705
[chmod 755
work]) fine , dandy. not matters, changed folder in 701 (to hide it, still executable server).
i still don't understand why .php file worked on other server when set 644?? how apache execute script without world permission?? apache not need world permission?? few questions still have...
Comments
Post a Comment