Redirect to html page

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Noodle7
    New Member
    • Jul 2006
    • 4

    Redirect to html page

    Hi ,
    Firstly I am new to this a forum and a big time beginner at php.
    My Question is I am needing to create a search function on the homepage and this search function will direct the user to another page depending on what they enter in
    the search area... eg. if they enter 100000 on the home page being www.blahbla.com - this will take them to the page www.blahbla.com/100000.htm ..

    anyway ideas?
    Thanks
    Melissa
  • ronverdonk
    Recognized Expert Specialist
    • Jul 2006
    • 4259

    #2
    Are you looking for a real search function, as in searching for text embedded in files or data base, or just a link-creator?

    Ronald :cool:

    Comment

    • Noodle7
      New Member
      • Jul 2006
      • 4

      #3
      I suppose I am looking for a link-creator , if however they type in an invalid number it must be redirected to another page stating that...make sense?
      Melissa :)

      Comment

      • ronverdonk
        Recognized Expert Specialist
        • Jul 2006
        • 4259

        #4
        I have a little piece of code.
        index.php is the main, page1000.php and page2000.php are the existing pages, doesnotexist.ph p catches the non-existing page requests.
        [PHP]
        index.php:
        <?php
        if (isset($_POST['pageno'])) {
        if (file_exists('p age'.$_POST['pageno'].'.php')) {
        header('Locatio n: page'.$_POST['pageno'].'.php');
        }
        else {
        header('Locatio n: doesnotexist.ph p');
        }
        }
        ?>
        <html>
        <body>
        <form action="index.p hp" method="post">
        Enter the requested page <input type="text" name="pageno"/><br/>
        <input type="submit" value="Request page">
        </form>
        </html></body>

        page1000.php and page2000.php:
        <?php
        echo '<h3>You have reached page1000</h3>
        <a href="index.php ">Click here</a> to go back to our main page.';
        ?>
        <?php
        echo '<h3>You have reached page2000</h3>
        <a href="index.php ">Click here</a> to go back to our main page.';
        ?>
        doesnotexist.ph p:
        <?php
        echo '<h3>This page does not exist our our system. Please retry.</h3>
        <a href="index.php ">Click here</a> to go back to our main page.'
        ?>
        [/PHP]

        Hope it helps.

        Ronald :cool:

        Comment

        Working...