Results 1 to 5 of 5

Thread: [RESOLVED] Error When Redirecting a Page

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    May 2004
    Location
    Quetta-Pakistan
    Posts
    852

    Resolved [RESOLVED] Error When Redirecting a Page

    Hi,
    I am developing a login system. I want that if user provide correct info, the page redirects to welcome.php , but its giving an error "Warning: Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\MyWork\LoginDemo.php:18) in C:\xampp\htdocs\MyWork\LoginDemo.php on line 33"
    my code is as under
    Code:
        if ($count >= 1) {
            echo "My User Name : " . $username . "<br/>";
            echo "My password  : " . $password;
            header('Location: WelcomePage.php'); /* Redirect browser */
        } else {
            echo "Invalid User";
        }
    ** line 33 is header('Location: WelcomePage.php'); /* Redirect browser */

  2. #2
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,123

    Re: Error When Redirecting a Page

    What browser are you using? Have you tried different browsers? I also experienced same error before and my solution I think was to use JavaScript to move to another location.
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    May 2004
    Location
    Quetta-Pakistan
    Posts
    852

    Re: Error When Redirecting a Page

    Thanks for the reply,
    I am using FireFox, issue is that if i create a new PHP file and write the same code for redirection, it works. It is just showing error within this project

  4. #4
    WiggleWiggle dclamp's Avatar
    Join Date
    Aug 2006
    Posts
    3,527

    Re: Error When Redirecting a Page

    What is on line 18 of your code?

    You are either using "echo" or you close and open your php tags...

    There should be no HTML output prior to a header.

  5. #5

    Thread Starter
    Fanatic Member
    Join Date
    May 2004
    Location
    Quetta-Pakistan
    Posts
    852

    Re: Error When Redirecting a Page

    On line 18, there was an If Statement, i deleted it.

    There were few other HTML commands like <br> , <hr> etc before HEADER, delete all. Now its working fine

Posting Permissions

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



Click Here to Expand Forum to Full Width