if condition { load different page }

Discussion in 'PHP' started by lektrikpuke, May 6, 2008.

  1. #1
    Hi y'all,

    I'm sorry if I'm asking this again, but how can I do a conditional statement in PHP that will jump out of the page/php and go to another page.

    I have a search page, and if certain keywords are entered, I don't want the search page to be displayed (with or without results). Instead, I want a new page (associated with the keyword) to load. Basically, jump off the php page.

    Thanks.

    Rob
     
    lektrikpuke, May 6, 2008 IP
  2. mwasif

    mwasif Active Member

    Messages:
    816
    Likes Received:
    23
    Best Answers:
    1
    Trophy Points:
    70
    #2
    mwasif, May 6, 2008 IP
  3. lektrikpuke

    lektrikpuke Well-Known Member

    Messages:
    297
    Likes Received:
    1
    Best Answers:
    1
    Trophy Points:
    113
    #3
    Thanks. Unfortunately, that's not going to work because (and sorry for not mentioning/explaining this before) I want it to work on the submission of my form, which has to be hardcoded, right?

    <form name="searchform" method="POST" action="some_page.php">

    What I'd like to be able to do is make the action of the post a variable, so that I can direct to other pages. Probably asking too much.

    <form name="searchform" method="POST" action="$some_var">
    if(condition){$some_var="http://page.html");}
     
    lektrikpuke, May 6, 2008 IP
  4. Sabbir

    Sabbir Banned

    Messages:
    210
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    58
    #4
    how you are checking the condition. the keywords here will represent as string and you need to use some string manipulation function.
     
    Sabbir, May 7, 2008 IP
  5. bartolay13

    bartolay13 Active Member

    Messages:
    735
    Likes Received:
    14
    Best Answers:
    1
    Trophy Points:
    98
    #5
    in php just use header("Location: yourpage.php");

    switch($a)
    {
    case 1:
    header("Location: yourpage.php");
    break;
    case 2:
    header("Location: yourpage2.php");
    break;
    }

    also

    submit your form to a page where this code resides..

    there are many functions you can use in redirecting to other page/s
     
    bartolay13, May 7, 2008 IP