linuxStat PHP Documentation

PHP Function - isset

There is a second way to detect selected entries in a set of check boxes:
Investment Interest:
Domestic stock funds
Global stock funds
Domestic bond funds
Global bond funds
Money market funds



Corresponding to the selections not made there are no entries in the _GET map.
This can be detected by using the PHP function isset().


We will include a PHP program in a file called detectselectedwithisset.php.
This program will detect check boxes selected by the user by using the function isset().


An HTML document containing the above check boxes is the following.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/transitional.dtd">
<html>
<head>
<meta http-equiv=Content-Type content="text/html; charset=us-ascii">
<title>Executed on Dell Server, Intel Processor, created on HP laptop</title>
</head>
<body bgcolor="#0F243E" text="#FFFF00" lang=EN-US>
<form action="detectselectedwithisset.php" method="get">
Investment Interest:<br><br>
<input type="checkbox" name="InvIntDS" value="Domestic Stock">Domestic stock funds<br>
<input type="checkbox" name="InvIntGS" value="Global Stock">Global stock funds<br>
<input type="checkbox" name="InvIntDB" value="Domestic Bond">Domestic bond funds<br>
<input type="checkbox" name="InvIntGB" value="Global Bond">Global bond funds<br>
<input type="checkbox" name="InvIntMM" value="Money Market">Money market funds<br>
<br><br>
<input type="submit" name="Submit" value="Submit" size="30">
</form>
</body>
</html>

The following is the PHP code I will save in detectselectedwithisset.php file.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/transitional.dtd">
<html>
<head>
<meta http-equiv=Content-Type content="text/html; charset=us-ascii">
<title>Executed on Dell Server, Intel Processor, created on HP laptop</title>
</head>
<body bgcolor="#0F243E" text="#FFFF00" lang=EN-US>
<?php
# Example of check box data in _GET map
print "Your interests are:<br>";
$nameExists = isset($_GET["InvIntDS"]);
if ($nameExists) {
   print "{$_GET["InvIntDS"]}<br>";
}
$nameExists = isset($_GET["InvIntGS"]);
if ($nameExists) {
   print "{$_GET["InvIntGS"]}<br>";
}
$nameExists = isset($_GET["InvIntDB"]);
if ($nameExists) {
   print "{$_GET["InvIntDB"]}<br>";
}
$nameExists = isset($_GET["InvIntGB"]);
if ($nameExists) {
   print "{$_GET["InvIntGB"]}<br>";
}
$nameExists = isset($_GET["InvIntMM"]);
if ($nameExists) {
   print "{$_GET["InvIntMM"]}<br>";
}
?>
</body>
</html>




Click the following link to execute the above PHP code
by my server's PHP interpreter.

Try the above example   Next  Index

If you would like to learn more about isset(),
click the following link.

More on isset()