For example: I have a submit form in which the user has entered some information (login for example), and I need to check if there is such a login in the database. And it is necessary that if such a login already exists in the database, then the inscription immediately appears that “Such a login has already been registered”.
Answer 1, authority 100%
AJAX to help. On the server, on the same PHP, make wrappers to the database functions (with appropriate prohibitions and check everything that is possible so that nothing is done in the database) and make requests to it from JS.
There are a lot of articles on this topic on the Internet =) And examples.
JS (AJAX) - & gt; PHP: is 'Vasya' in the database? PHP: Uh-huh, the question is normal, there is no palette, now I will ask the information bureau. PHP - & gt; MySQL: Do you know 'Vasu'? MySQL - & gt; PHP: uh-huh PHP - & gt; JS: yes, let him try another login, because there is no need for a second Vasya.