Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Affecting <select> boxes with PHP_SELF 1

Status
Not open for further replies.

yumbelie

Programmer
Dec 31, 2002
96
GB
Hi, how exactly do I use $PHP_SELF / $_SERVER['PHP_SELF'] to submit a page toitself, and consequently pass the variables from one select box, so that a mysql query can be made to populate the second select box ?

Thanks guys
 
In cases where you have a script producing an HTML form which will submit back to the same script, your script needs to be able to tell whether it is being run for the first time or subsequent times.

One thing I do is to make sure that I use POST-method forms, then have the script check $_POST for the presence of my form fields. If the fields I need do not exist in $_POST, then the script will output the initial form. If the required field does exist in $_POST, you can use its value to perform subsequent activities.

The basic outline of the script is then:

if (array_key_exists ('myfield', $_POST))
{
//output initial form
}
else
{
//process input and output subsequent HTML
} Want the best answers? Ask the best questions: TANSTAAFL!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top