Buongiorno a tutti
premesso che non sono un esperto, sto cercando di fare una ricerca per user o nome su AD.
Ho trovato degli esempi e ho implementato due pagine:
- test_ad.php
- leggi.php
Non riesco a passare variabili (credo) e la ricerca rilascia tutti i nominativi ma non ricerca per nome.
Potete aiutarmi? Grazie in anticipo.
test_ad.php
Codice PHP:
<!DOCTYPE html>
<html>
<head>
<title>Autocomplete textbox using jQuery, PHP and LDAP</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css"; />
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>;
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js"></script>;
<style>
ul{
background-color:#eee;
cursor:pointer;
}
li{
padding:12px;
}
</style>
</head>
<body>
<br /><br />
<div class="container" style="width:500px;" action="test_ad.php" method="POST">
<h3 align="center">Autocomplete textbox using jQuery, PHP and LDAP</h3><br />
<label>Enter Name</label>
<input type="text" name="search-box" id="search-box" class="form-control" placeholder="Enter Name" />
<div id="suggesstion-box"></div>
</div>
</body>
</html>
<script>
$(document).ready(function(){
$('#search-box').keyup(function(){
//var query = $('#search-box').val();
var query = $('#search-box').val();
if(query != '')
{
$.ajax({
url:"leggi.php",
method:"REQUEST",
data:{query:query},
success:function(data)
{
$('#suggesstion-box').fadeIn();
$('#suggesstion-box').html(data);
}
});
}
});
$(document).on('click', 'li', function(){
$('#search-box').val($(this).text());
$('#suggesstion-box').fadeOut();
minLength: 3
});
});
</script>
leggi.php
Codice PHP:
<!DOCTYPE html>
<html>
<head>
<title>Autocomplete textbox using jQuery, PHP and LDAP</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css"; />
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>;
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js"></script>;
<style>
ul{
background-color:#eee;
cursor:pointer;
}
li{
padding:12px;
}
</style>
</head>
<body>
<br /><br />
<div class="container" style="width:500px;" action="test_ad.php" method="POST">
<h3 align="center">Autocomplete textbox using jQuery, PHP and LDAP</h3><br />
<label>Enter Name</label>
<input type="text" name="search-box" id="search-box" class="form-control" placeholder="Enter Name" />
<div id="suggesstion-box"></div>
</div>
</body>
</html>
<script>
$(document).ready(function(){
$('#search-box').keyup(function(){
//var query = $('#search-box').val();
var query = $('#search-box').val();
if(query != '')
{
$.ajax({
url:"leggi.php",
method:"REQUEST",
data:{query:query},
success:function(data)
{
$('#suggesstion-box').fadeIn();
$('#suggesstion-box').html(data);
}
});
}
});
$(document).on('click', 'li', function(){
$('#search-box').val($(this).text());
$('#suggesstion-box').fadeOut();
minLength: 3
});
});
</script>