Bluehost.com Web Hosting $6.95

Double drop down menu with PHP

This is a discussion on Double drop down menu with PHP within the PHP General forums, part of the PHP Programming Forums category; Has anyone had any luck getting a double drop down menu to work with PHP? I can get the menu - ...


Go Back   Usenet Forums > PHP Programming Forums > PHP General

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 07-15-2003
Robert Bowen
 
Posts: n/a
Default Double drop down menu with PHP

Has anyone had any luck getting a double drop down menu to work with PHP?
I can get the menu - which is written in javascript to work, but I can't
figure out how to pass the value of what the user selects to PHP.



What I want to do is have a small online address book for the school
district I work for. Users visiting our page would be able to select from
searching by Last Name, Department or Building. What I wanted was if the
user selects Department a menu opens up with all the departments listed,
same for buildings.



Here is the page with the javascript I am using. It simply redirects the
user to a URL based on their selection.

http://www.trans4mind.com/personal_d...Doublemenu.htm



My only thought is to pass the selection through the URL, but then I have to
turn on register_globals and that makes me nervous.



Any thoughts/suggestions would be appreciated.



Thanks,

Robert Bowen

Baldwin UFSD


Reply With Quote
  #2 (permalink)  
Old 07-15-2003
Sam Williams
 
Posts: n/a
Default Re: Double drop down menu with PHP

On Tue, 15 Jul 2003 00:21:15 +0000, "Robert Bowen"
<bowenr@baldwin.k12.ny.us> wrote:

<snip>


> My only thought is to pass the selection through the URL, but then I
> have to turn on register_globals and that makes me nervous.


You do not have to turn register_globals on to do this, you just have to
access the values through $_GET, $_POST or $_REQUEST depending on which
method the javascript uses. If it appends the users selection to the url,
use $_GET.

To improve security, you can check that the values that are sent are what
you are expecting - the safest way would be to give each item in the menus
a number.. this would result in a url like this:

http://some.domain.com/index.php?menu1=2&menu2=5

These values can be accessed in PHP by:

$choice_1 = $_GET['menu1']; // should be 2

and

$choice_2 = $_GET['menu2']; // should be 5

then, simply use something like:

if(!is_numeric($choice_1){
echo "Selection must be a number";
return FALSE;
}

to check that you have been given a sensible input. You may also want to
check that the number you receive is (a) an integer and (b) is within a
certain range.

Cheers,

Sam.



>
>
> Any thoughts/suggestions would be appreciated.
>
>
>
> Thanks,
>
> Robert Bowen
>
> Baldwin UFSD

---
Posted via news://freenews.netfront.net
Complaints to news@netfront.net
Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 07:14 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0