Jump to content

Please Help Me With This


intenseone345

Recommended Posts

Hello, when i tested this php script below i got the following error message,

 

ERROR SHOWN ON BROWSER:

------------------------

Post message

Warning: Cannot modify header information - headers already sent by

(output started at /hermes/bosweb/web176/b1761/ipw.tomagr/public_html/maila.php:23)

in /hermes/bosweb/web176/b1761/ipw.tomagr/public_html/maila.php on line 39

------------------------

 

The code is in its own page just as its shown below, simple word check, then post the comments

to a flat file and emails me with posted comment.

the, $post = $_POST['comments']; reffers to the form on another page that the

comments are comming from. I want to know what im doing wrong in this script?

Any ideas i'd love to hear, thanks

 

the php script :

 

<?

$post = $_POST['comments'];

$words = array('murmer', 'frog', 'bat', );

 

$continue = true;

 

foreach ($words as $word) {

 

if (preg_match('/\b' . $word . '\b/i', $post)) {

$continue = false;

header("Location: mysite.html");

exit();

 

}

 

}

 

if (!$continue) {

echo 'Bad boy!';

}

 

else {

echo 'Post message';

}

$fc = fopen("comments.txt","a+b"); //opens the file to append new comment -

fputs($fc,$_POST['comments']."\n\n\nNewComment->"); //writes the comments followed by a

fclose($fc); //closes the files

 

if(sizeof($_POST)) {

$body = "";

while(list($key, $val) = each($HTTP_POST_VARS)) {

$body .= "$key: $val \n";

}

 

mail("[email protected]", // to

"Subject Line",

$body);

 

header("Location: mysite.html");

}

 

// end form processing

?>

Link to comment
https://forums.phpfreaks.com/topic/185916-please-help-me-with-this/
Share on other sites

To answer your question even if you didn't read the sticky. You are outputting data then trying to redirect the browser using "header("location:blah");". But since you already echo'd something, headers were already sent. Either don't echo and redirect or put output buffering on. Personally, I don't see why you would ever echo something before you send a header anyways. (It doesn't work, and they wouldn't see it anyways.)

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.