Re: Serving pages based on user input

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Jochem Maas wrote:
Prasad Chand schreef:
Hi,

I am fairly new to PHP. I would like to serve a page to a user based on his input. Say, I have a page 1 where user has 3 options(drop down menu). Based on his selection I would like a php script to direct him to another page (to pages 2,3,4 based on what he selected). I am unable to figure how to do this in php. Can you please give me some pointers.

Is there any function which takes path and directs the user to that page?

millions of them, but not in php itself this is the kind of thing
you have to write yourself.

you don't really want to redirect the user at all (because it's a completely
unecessary round-trip that will cause your server to have to handle another
request when you already have the required info needed to display the relevant content), what you want to do is parse the input from the form and then run the relevant
code to generate the relevant content. e.g.

if (isset($_POST['selected_page'])) {
    switch ($_POST['selected_page']) {
        case 'page1':
            include 'myfirstpage.php';
            exit;
        case 'page2':
            include 'mysecondpage.php';
            exit;
        case 'page3':
            include 'mythirdpage.php';
            exit;
        default:
            die('go away smelly hacker!');
    }
} else {
    // output your page selection form here or something.
}

that's just one lame example, there are as many ways to skin this
cat as there are cats. might I suggest you go and read a few basic
tutorials because what your asking is as basic as it gets ... namely
take some user input and use it to determine what to output ...



Thanks for your reply Jochem. I will keep your advice in mind. This is off-topic, but the reason I was touchy about includes was because it could create seo problems.

http://forums.digitalpoint.com/showthread.php?t=31519

Thanks again,
Prasad



Thanks,
Prasad



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux