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 ?
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:
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.