Finally, we get to the HTML output of the script. This set of code prints out the form that
is used for performing the searches.
<?php
//Make Form
echo "<CENTER><FORM ACTION=\"$PHP_SELF\" METHOD=\"GET\">";
echo "Search in:<SELECT NAME=\"SERVER_ID\">";
//Loop Through and Create SELECT OPTIONs
for($i=0; $i<count($LDAP_NAME); $i++)
echo "<OPTION VALUE=\"$i\">".$LDAP_NAME[$i]."</OPTION>";
echo "</SELECT><BR>";
echo "Search for:<INPUT TYPE=\"text\" NAME=\"common\">";
echo "<INPUT TYPE=\"submit\" NAME=\"lookup\" VALUE=\"go\"><BR>";
echo "(You can use * for wildcard searches, ex. * Stanley will find all Stanleys)<BR>";
echo "</FORM></CENTER>";
?>
The only portions of this code that is interpreted is $PHP_SELF which is a global
constant for the name of the script itself and the loop that creates the SELECT box from
our $LDAP_NAME variable.
Echo Results
Now that all of the work has been done, we print out the result set. If no results were
returned, a message is given stating the same.
//Assign Result Set to an Array
$result_array = ldap_get_entries($connect_id, $search_id);
}
else
{
//Echo Connection Error
echo "Could not connect to LDAP server: $LDAP_SERVER[$SERVER_ID]";
}
//Make Form
echo "<CENTER><FORM ACTION=\"$PHP_SELF\" METHOD=\"GET\">";
echo "Search in:<SELECT NAME=\"SERVER_ID\">";
//Loop Through and Create SELECT OPTIONs
for($i=0; $i<count($LDAP_NAME); $i++)
echo "<OPTION VALUE=\"$i\">".$LDAP_NAME[$i]."</OPTION>";
echo "</SELECT><BR>";
echo "Search for:<INPUT TYPE=\"text\" NAME=\"common\">";
echo "<INPUT TYPE=\"submit\" NAME=\"lookup\" VALUE=\"go\"><BR>";
echo "(You can use * for wildcard searches, ex. * Stanley will find all Stanleys)<BR>";
echo "</FORM></CENTER>";