Re: Error when execute header('location: otherpage.php') after email been sent out. Any Workaround?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi all,
Yes, you are right, it was due to echo for testing purpose not been commented out prior to header(). However, there is hidden root cause too -- PHPMailer will echo invalid address to the screen. When I have tested with 1 valid email address and 1 invalid with something@locahost, PHPMailer will echo out the invalid something@localhost. However, in this case, $mail->send() still will return value of TRUE as long as at least 1 email been sent out. After I have commented out all these [echo], no more header issue occur again.

It's works too using Floyd's recommended javascript! However, the message will echoed out first before redirect to index.php, but this is fast enough to be neglectable.

I have one more question regarding error logging.
I have set as below:

ini_set('log_errors', 1);
ini_set('error_log', "http://domain.com/log/logfile.txt";);
ini_set('error_reporting', 'E_ALL');
ini_set('error_append_string', '\r\n');

I have simulated an error which can be displayed on screen because I've put ini_set('display_errors',1).
However, the error was not been logged.

Which format should I used for log file? *.log or *.txt?

Since I'm using third party web hosting, I can only access web directory, should I use
[http://domain.com/log/logfile.*] or
[C:\some_path\domain.com\log\logfile.*] or just
[/log/logfile.*]?

Thanks!
Keith


"Floyd Resler" <fresler@xxxxxxxxxxxxx> wrote in message news:A536E452-54A2-4F55-8AE0-28E875A59D02@xxxxxxxxxxxxxxxx
Another solution would be to use JavaScript. In your process.php script you could do this:
print<<<here
<script language="javascript">
window.location.href="index.php"
</script>
here;

Not strictly a PHP solution but it works.

Take care,
Floyd

On Aug 28, 2009, at 5:34 AM, Ashley Sheridan wrote:

On Fri, 2009-08-28 at 17:32 +0800, Keith wrote:
I have a user sign up page that collects sign up information from user with
form.
This form will then be submitted to another process.php page for setting up
the user account and send email to the user.
After the email been sent out, the user will be directed back to homepage
with header("location: index.php").
However, error happen with warning: [Cannot modify header  information -
headers already sent by...]
Any workaround for this?

Thanks for help!
Keith




You don't need a workaround. The header("Location...") thing will only
work if you have not sent any content to the browser yet. That  includes
even a single space or newline.

It looks like in your process.php page, something is being output to  the
browser. Are you able to do a code dump of that page?

Thanks,
Ash
http://www.ashleysheridan.co.uk




--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux