Appel d'une fonction avec un Input text
Bonjour à tous,
Voila, j'essaie d'effectuer une fonction lors du changement de mon Input text pour effectuer des recherches sur l'annuaire LDAP. voici le code :
Code:
1 2 3
| <FORM Method="POST" Action="Index.php">
<input type="text"size="15" id="txtRecherche" onchange="Recherche()" />
</FORM> |
Et voici la fonction Recherche() :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
| <?php
function Recherche(){
//vérifier d'abord que le texte à rechercher est rempli avant d'établir la connexion ldap
if(isset($_POST["txtRecherche"]) AND (!empty($_POST["txtRecherche"]))){
//----------------------Connexion avec la serveur LDAP--------------------------
$connect=ldap_connect("$server");
if ($connect) {
//------------------------------Authentification--------------------------------
$ident=ldap_set_option($connect,LDAP_OPT_PROTOCOL_VERSION,3);
$ident=ldap_bind($connect,$rootdn,$rootpw);
// -------------------------Recherche dans l'annuaire--------------
if ($ident){
$search=ldap_search($connect,"ou=people,dc=fresnel,dc=fr","uid=*".$_POST["txtRecherche"]."*");
$nbLigne=ldap_get_entries($connect,$search);
print($_POST["txtRecherche"]);
echo $_POST["txtRecherche"];
}
}
}
}
?> |
Et j'ai naturellement fait un include sur la page index.php :
Code:
1 2 3 4
| <?php
include ("head.php");
include("fonctions.php");
?> |
Je n'arrive pas à voir le souci... merci de votre aide.