Forum Moderators: coopster
I am using this simple script to store newsletter subscribers in a .txt file (not confident enough for SQL yet).
Code:
<?php {
$emailAddress = $_POST['em'];
$filename = "subscribers.txt";
$content = "$emailAddress\n";
$fp = fopen($filename, "a");
$fw = fwrite( $fp, $content );
fclose( $fp );
header("Location: [#*$!xx.co.uk...]
}?>
While the email address storage function is working fine, I'm not being redirected to my thank you page afterwards (browser stays at the mailhandler script, which is of course a blank page...
Can anyone point out what I've done wrong?
Regards,
Even more simple: In that we can't see the entire file from which your code snippet comes, there must be no output at all before invoking a header() (and other similar) function. The
<?php must be the very first line, and there must not be any extra spacebars in your script (like at the end of a line before the carriage return) before the header() function. More complicated is the idea that your file writing operation may be dumping stuff into the buffer, which is also a problem for the header() function.
Of course (as you already have) check the PHP manual page for header() [us3.php.net] to make sure you are following all of the rules. It's usually something simple.