[RESOLVED] Warning: Cannot modify header information - ...
Hi, I know nothing about PHP. All I know is basic HTML. But I want a contact form on my website and finally found this PHP form:
I uploaded the folder to my webspace (only changed the email address in the .php file) and tested it. It worked fine.
I managed to incorporate the whole thing into my website. But when I clicked 'Submit', I got an error saying:
error; you need to submit the form!
Warning: Cannot modify header information - headers already sent by (output started at /www/htdocs/my-webspace-name/contact/form-to-email.php:4) in /www/htdocs/my-webspace-name/contact/form-to-email.php on line 34
But I received the form email despite the error message.
When I removed
echo "error; you need to submit the form!";
from the form, it worked fine again and the thank you page came up.
1st Question: Does anybody know why this is happening?
2nd Question: What does - if(!isset($_POST['submit'])) - do and do I actually need it for any security reasons, or can I just delete it?
My site is hosted on a Linux server, if that makes any difference.
Remember, I know nothing about PHP and using 'Old Fool' as a username isn't much of an exaggeration. Please take it easy on me.
The error is being triggered by the echo. You cannot output anything to the browser before sending header()
I'm guessing your form is supposed to have an input with a name of "submit" e.g.
<input type="submit" name="submit">
Many thanks M@tt for pointing me in the right direction. When I checked for <input type="submit" name="submit">, I noticed that one submit was spelled with a capital letter and remembered that I read somewhere that PHP is case sensitive. It finally works!
Thanks again, Robert
Users Browsing this Thread
There are currently 2 users browsing this thread. (0 members and 2 guests)