Results 1 to 10 of 10

Thread: goto another page after updating...

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Mar 2001
    Location
    India
    Posts
    117

    goto another page after updating...

    i want to go to my main page (main.php) after updating my records from update page (update.php). how can i do it? please help...

    ram

  2. #2
    PowerPoster lintz's Avatar
    Join Date
    Mar 2003
    Location
    The 19th Hole
    Posts
    2,697

    Re: goto another page after updating...

    You could use something like this....

    PHP Code:
    header("location: main.php"); 

  3. #3
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: goto another page after updating...

    Using a header is correct.

    If it's after a processing POST request, don't send any response data (make sure the PHP code starts at the very top of the file, and there is nothing being echo()'d or otherwise sent) and use a 303 redirection code to prevent the POST request from being cached by the browser:
    PHP Code:
    header('HTTP/1.1 303 See Other');
    header('Location: main.php'); 
    This will ensure that the back and forward controls work correctly without any irritating "This page contains POSTDATA that has expired from cache" messages.

  4. #4
    Fanatic Member
    Join Date
    Jan 2005
    Location
    Cebu
    Posts
    607

    Re: goto another page after updating...

    But what about after the echoes? What if the update.php has some "Something is updated successfully!" and then pause for a moment and then redirect the the main.php? How do you guys do that?

    Thanks.

  5. #5
    PowerPoster lintz's Avatar
    Join Date
    Mar 2003
    Location
    The 19th Hole
    Posts
    2,697

    Re: goto another page after updating...

    You could use a refresh redirect.

    HTML Code:
    <!--4 = number of seconds until refresh-->
    <meta HTTP-EQUIV="REFRESH" CONTENT="4; URL=main.php">
    EDIT: So i did Dclamp
    Last edited by lintz; Jul 6th, 2007 at 06:18 PM.

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

    Re: goto another page after updating...

    @Lintz: you used a Visual Basic comment,
    php comment is:
    PHP Code:
    //blah OR:
    /* blah */ 
    or html comment:
    HTML Code:
    <!-- Comment -->
    My usual boring signature: Something

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

    Re: goto another page after updating...

    You should have it set to HTML code, and have the HTML comment since META is HTML not PHP

    come one, you know better, your smarter then that :P

    if your problem is resolved, please select "Thread Tools > Set as Resolved", and give rep accordingly
    My usual boring signature: Something

  8. #8
    PowerPoster lintz's Avatar
    Join Date
    Mar 2003
    Location
    The 19th Hole
    Posts
    2,697

    Re: goto another page after updating...

    Can't you see I did a bit of both, just like in your post

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

    Re: goto another page after updating...

    well now it looks like a child wrote that code. here, make it like this:

    HTML Code:
    <!-- 4 = number of seconds until refresh -->
    <meta HTTP-EQUIV="REFRESH" CONTENT="4; URL=main.php"> 
    My usual boring signature: Something

  10. #10
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: goto another page after updating...

    Oh please, Dylan! The thread starter hasn't even responded yet.

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