Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8659045
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T15:54:35+00:00 2026-06-12T15:54:35+00:00

Many thanks in advance for even attempting to present a solution. I’m having trouble

  • 0

Many thanks in advance for even attempting to present a solution.
I’m having trouble with a simple html contact form.
The form’s method is set to post and it’s action is sent to a php file.
At the end of the PHP file the form is sent to, there is a basic location:redirection.

ex) header("Location: ../index.htm");

I configured my php.ini file (Apache) to display the php error(s).
This is what I’m shown:

"Cannot modify header information - headers already sent by (output started at /home2/jwarddes/public_html/newTest/php/contact.php:2) in /home2/jwarddes/public_html/newTest/php/contact.php on line 20"

Line 20 of my code is my header("location:... redirect. This appears to be fine, yet something keeps throwing an error.
Needless to say, I’m stumped.

Could someone please try their hand at a solution or kindly nudge me in the right direction?

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T15:54:36+00:00Added an answer on June 12, 2026 at 3:54 pm

    that is a common problem.

    make sure you do not have any output (even a simple space at the top of the page) as that will send the headers prior to your redirect.

    Possible Solutions are the following.

    ob_start();
    

    in the top of your page and

    ob_end_flush(); 
    

    at the bottom might solve your issue.

    Also, I have this special function below which do a very smart redirect, try it out and let me know 🙂

    /**
     * redirect()
     * 
     * Attempts to redirect the user to another page.
     * It tries to PHP header redirect, then JavaScript redirect, then try http redirect.
     * The following redirection method is only attempted if the previous redirection method attempt has failed  
     *  
     * @param mixed $url To be redirected to
     * @return nothing
     */
    function redirect($url)
    {
            if (!headers_sent())
            { //If headers not sent yet... then do php redirect
                    header('Location: ' . $url);
                    exit;
            } else
            { //If headers are sent... do java redirect... if java disabled, do html redirect.
                    echo '<script type="text/javascript">';
                    echo 'window.location.href="' . $url . '";';
                    echo '</script>';
                    echo '<noscript>';
                    echo '<meta http-equiv="refresh" content="0;url=' . $url . '" />';
                    echo '</noscript>';
                    exit;
            }
    } //==== End -- Redirect
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Many thanks in advance. When running the ASP.NET Development Server, everything is working fine.
Many thanks for the advice you have given me thus far. Using testbenches is
Following on from my earlier question about creating Address Books (many thanks Peter!), I
Well to me Perl sometimes looks abit Abracadabra so many thanks for the patience
Many people use this method to add animation on switching views. When I try
I have a menu made with HTML, using a simple UL with lots of
I'm attempting to create a simple web application for some personal development, but I've
I am still new to PHP, and even newer to Drupal's Form API. I'm
I have an old website - written in asp. The contact form uses a
I am having some trouble with Xcode not updating files that I have updated

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.