There are several form fields. You need to search for one of the fields. In this case, in the phone
field, when typing more, for example, 4-5 first characters (numbers). If there are such records in the table, with a certain prefix entered by the user in the input field, then output the first 5 results and automatically fill in the remaining fields when one of the results is selected.
Here is the form handler code:
$zakaz = $_POST['zakaz']; $tel= $_POST['phone']; $kol= $_POST['kol']; $segod = $_POST['segod']; $avto = $_POST['avto']; $stat = $_POST ['stat']; $sql = "insert into zakaz_table (zakaz, phone, kol, datavremya, member, segod, avto, stat) values ('$zakaz', '$tel', '$kol', DATE_ADD(now(), INTERVAL 0 HOUR), '$usrname', '$segod', '$avto', '$stat')"; mysql_query($sql) or die(mysql_error()); /* Закрываем соединение */ $mess = " Заказ отправлен на обратку "; //echo $sql; header("location:index.php?mess=$mess");
Correspondingly, zakaz
is the client's address, and phone
is the phone, the rest of the fields are not needed for auto-completion.