[RESOLVED] Warning: Cannot modify header information - ...
Results 1 to 3 of 3

Thread: [RESOLVED] Warning: Cannot modify header information - ...

  1. #1
    Junior Member
    Join Date
    Apr 2012

    resolved [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.

    Thanks, Robert

  2. #2
    Syntax Error
    Join Date
    Feb 2003
    San Diego, CA
    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">

  3. #3
    Junior Member
    Join Date
    Apr 2012
    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

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts