SitePoint Sponsor

User Tag List

Results 1 to 9 of 9

Thread: Help NEWBIE pls

  1. #1
    SitePoint Member
    Join Date
    Feb 2005
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Help NEWBIE pls

    hello, i'm relatively new to php and what i need to know is how can i open a web page in a php 5 code flow.

    For Example:

    if (a < b) open_page_named_x.php;

    Thanks in advance.

    -GT

  2. #2
    SitePoint Addict launchcode's Avatar
    Join Date
    Dec 2004
    Location
    Bristol, UK
    Posts
    259
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    When you say "open a page" do you mean redirect the browser to that page, or something else? If you mean to redirect the browser then just use: header('Location: open_page_named_x.php");
    Richard Davey

    Launchcode
    PHP Security Guide. Think your scripts are secure? Think again.

  3. #3
    SitePoint Member
    Join Date
    Feb 2005
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    but that can't be done after the header is sent can it?

  4. #4
    SitePoint Zealot
    Join Date
    Jan 2005
    Posts
    147
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    no it can't be done after header is sent. But you should be checking that before the page loads anyway. then you wouldn't have an issue with the headers being sent and you can refirect anywhere you want.

  5. #5
    dooby dooby doo silver trophybronze trophy
    spikeZ's Avatar
    Join Date
    Aug 2004
    Location
    Manchester UK
    Posts
    13,806
    Mentioned
    158 Post(s)
    Tagged
    3 Thread(s)
    you could put something together like
    PHP Code:
    if($a $b) {
    header("Location: page.php");
    } elseif(
    $a $b) {
    header("Location: page_2.php");

    You could also tidy this up bit by using switch()

    SpikeZ
    Mike Swiffin - Community Team Advisor
    Only a woman can read between the lines of a one word answer.....

  6. #6
    SitePoint Member
    Join Date
    Feb 2005
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    so there is no way to open a web page in a php block code after the http header is sent? Nothing like open(url)?

  7. #7
    dooby dooby doo silver trophybronze trophy
    spikeZ's Avatar
    Join Date
    Aug 2004
    Location
    Manchester UK
    Posts
    13,806
    Mentioned
    158 Post(s)
    Tagged
    3 Thread(s)
    You could always drop javascript into the php script but I don't know how reliable it would be.
    Mike Swiffin - Community Team Advisor
    Only a woman can read between the lines of a one word answer.....

  8. #8
    SitePoint Zealot
    Join Date
    Jan 2005
    Posts
    147
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by spikeZ
    You could always drop javascript into the php script but I don't know how reliable it would be.

    It works fine as i have seen it used a lot. But then your bypassing the original intent of the if var. i mean if you know there is going to be an option for either/or then why not put it in before the redirect?

  9. #9
    SitePoint Member
    Join Date
    Feb 2005
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    the need for this is because i have a complex control flow with a http header to include in some flow directions (when i need to send html to browser), this way i have to always include in all those situations, i just thought that would be a simple way to just include once in the beggining and then redirct/open as required.

    Thanks all for your reply, i already changed the code for this not so much as i liked version


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
  •