I know this might make someone laugh at how green I am to php, but I need help. I have a simple form mail script (placed below) that I am using. It works fine until after you press the send button. I assume that the current page should be redirected to a thank you page. Instead I receive this message “Warning: Cannot modify header information - headers already sent by (output started at /home2/florido4/public_html/contact.php:1) in /home2/florido4/public_html/contact.php on line 29”.
I am not entirely sure what it means, but as it states the issue is with line 29. Ok I am a novice and the script as written may not be intended to return the thank you page, but that is what I want it to do. So can anyone give me some insight and an answer to my dilemma?
Well in case some someone might find this thread useful, I found the code needed to make this script work.
It is:
{echo “”;}
Place this code on line 29 or the line colored red. This line will work in regards to redirecting the visitor to a thank you page.
What I gathered from the information I found, is that the former line cannot be preceded by html text. Not fully sure what it means, but it directed me to find another script line to use in its place.
if someone feels the need to give me some insight it would Appreciated.
You can do your first code, but you can’t write anything before modify header.
Also an ENTER before <?php at first line make this error.
Thank You, I will take note of that.
true unless you use output buffering if you place
<?php
ob_start();
at the very top of your file it enables you to use headers anywhere you like if you use this remember to flush the buffer at the bottom of the file
ob_flush()
Thanx dave, but did you mean like this?
<?php ob_start(); (everythin in between) ob_flush() } ?>Plus could you explain what you meant when you said “you can’t write anything before modify header”?
yes that’s right. normally if your using a header function and you already have anything printed before it then it would throw an error.
you can have code before the header but not anything being shows such a print or echo unless you use output buffering
Thank you, dave you helped me understand far more then i asked for. ;D