SitePoint Sponsor

User Tag List

Results 1 to 5 of 5

Thread: redirecting?

  1. #1
    SitePoint Wizard lukeurtnowski's Avatar
    Join Date
    Mar 2003
    Location
    Coronado
    Posts
    1,582
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)

    redirecting?

    After my contact form is filled out why is my redirection code,
    PHP Code:
    header("Refresh: 3;url=http://www.google.com/"); 
    producing this
    Warning: Cannot modify header information - headers already sent by (output started at /home/fixmy1/public_html/masterasp/contact.php:13) in/home/fixmy1/public_html/masterasp/contact.php on line 42
    "Oh, and Jenkins--apparently your mother died this morning."

  2. #2
    Hosting Team Leader silver trophybronze trophy
    cpradio's Avatar
    Join Date
    Jun 2002
    Location
    Ohio
    Posts
    4,826
    Mentioned
    142 Post(s)
    Tagged
    0 Thread(s)
    because you have already sent output to the page, you can't have any output on the page prior to your header() statement. So no echo, print, or text outside of php tags.
    Be sure to congratulate xMog on earning April's Member of the Month
    Go ahead and blame me, I still won't lose any sleep over it
    My Blog | My Technical Notes

  3. #3
    SitePoint Wizard lukeurtnowski's Avatar
    Join Date
    Mar 2003
    Location
    Coronado
    Posts
    1,582
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    so, the only way I can use that statement is if its the first thing on my page?
    "Oh, and Jenkins--apparently your mother died this morning."

  4. #4
    Hosting Team Leader silver trophybronze trophy
    cpradio's Avatar
    Join Date
    Jun 2002
    Location
    Ohio
    Posts
    4,826
    Mentioned
    142 Post(s)
    Tagged
    0 Thread(s)
    the only way you can use header() and setcookie (for that matter) is if you have not started any output yet. You can have other PHP code above it, validation, emailing the form contents, writing/reading to a database, etc, but you can't have output.
    Be sure to congratulate xMog on earning April's Member of the Month
    Go ahead and blame me, I still won't lose any sleep over it
    My Blog | My Technical Notes

  5. #5
    Hosting Team Leader silver trophybronze trophy
    cpradio's Avatar
    Join Date
    Jun 2002
    Location
    Ohio
    Posts
    4,826
    Mentioned
    142 Post(s)
    Tagged
    0 Thread(s)
    Think of it this way:

    header() is a command to the browser to tell it to redirect to somewhere else. If you have output, the browser will begin its render process and won't acknowledge any commands, because it is past that stage and in the stage of drawing the output to the page for the user to see.
    Be sure to congratulate xMog on earning April's Member of the Month
    Go ahead and blame me, I still won't lose any sleep over it
    My Blog | My Technical Notes


Bookmarks

Posting Permissions

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