This is MADDENING!
I think what i'm going to have to do is accept the fact that the book example produces an error-- because it does! i visited this problem for the final time. i copied the code from the book line for line, changed the appropriate MySQL user info, and it does NOT allow for posting of a blank form w/out producing the following error.
Warning: Cannot modify header information - headers already sent
the reason i've been so fixated on this is that it expressly states in the book that there is a check to see if the form has data, and if not, the page is reloaded. halojoy, i should not have to rewrite the script-- this is not a function i'm laboring to implement into some application of my own-- it is merely an example written in a book, and i have been trying to figure out why it produces this error, when it specifically states the opposite-- that the page will be reloaded for the user to enter data if the form is blank.
so, i'm sorry to say that i really haven't learned anything from this. i have taken the advice that i've received in replies here, don't get me wrong-- i studied your workaround solutions, and i now know inside and out the logic on which this if statement is built
if ($_POST[op] != "send")
so, i guess i have learned something. it would have been nice if i could have learned why the author chose to use the
header("Location: sendmymail.php");
, but it's not really explained, just as the stripslashes usage is not explained.
and now, i've encountered another occurance of the
Warning: Cannot modify header information - headers already sent
from another example in the same book. it's because this is obviously the author's approach to this particular bit of script logic/ form control (that is, using the header("Location: reload bit). ugh! it's upsetting because there really is good content in this book! i have learned A LOT, but when it comes to the scripts, i feel like i'm walking on egg shells waiting for something to break, and yet it is so beyond my reach because i can't even figure out why the book's own scripts are erroneous, let alone, how to fix them!
sigh. i only hope that when / if i encounter this error on my own, the kind helpful people here at PHPBuilder.com will have mercy on me, and recall this ordeal!
grrr.