Hi,

I'm currently putting together a form as part of a larger PHP project. What I want to be able to do is, when this form is submitted, include a config.php file where I can read all the variables (such as the database info the store the values), and then once all the form information has been stored, redirect the user to another page.

I've tried to use the header ("Location: [url]http:///example.com[/url]") function but get an error due to the fact that I've already executed some PHP code by including the file. Is there any way around this, or any other method I could use? Any help would be really, really appreciated.

Thanks.

    best method is to keep any html, outputted php, commented php, javascript, ANY output after the header() function

    alternate, but isn't the greatest method is putting

    ob_start();

    at the top of your script to suppress the header error and it will act as normal

    www.php.net/ob_start

      Thanks for your prompt replies. If I were to put the header function at the top of the file, would the code below still take effect, or would the page just be redirected to the specified URL?

        it will redirect when it sees the header

        depends on what you are doing, but you could use the meta refresh

        or simply use the ob_start()

        if it isn't a terribly heavy page, you will probably be fine using it

          u wont get an error if u have executed any php code, u will get an error only if u output anything like html tags or output through echo or print.

          even if thereis nothing printed on the screen, sometimes there may be blank lines above the header() which cause the problem

          reg
          kevin

            Write a Reply...