Probably not very clear question ...

There is a registration form. The system validated input data (jQuery and php). When the focus (.blur) is removed from the input field, the text from the field is transferred by POST to the php script located in another folder. If you just need to count the number of characters in the name, for example, then everything is OK. And if you need to check the existence of a name in the database, you have to write all settings at the beginning of the script (mysql_connect ... mysql_select_db ...). But there are several such scripts. And there is a separate db.php file with database settings. The includ / require db.php file doesn’t want to connect. You don't want to transfer via java-script, because visible to anyone who wants to see ...

Who can what to advise?

UDP

The path may not be right. The structure is as follows:

forma.php db.php scripts/script.js php/valid.php 

Script.js is connected to form.php, which sends the data to valid.php. To connect db.php to valid.php you need to write require "... / db.php"?

Java: $ ("# name"). Blur (function () {var searchString = $ ("# name"). Val (); var data = 'name =' + searchString;

  if(searchString) { $.ajax( { type: "POST", url: "funk/check.php", data: data, beforeSend: function(html) { $("#rName").html("<img src='imgs/iLOAD.gif' width='24px' height='24px'/>"); }, success: function(html){ $("#rName").empty(); $("#rName").show(); $("#rName").append(html); } }); } return false; }); 

    2 answers 2

    I read the question and think "some kind of fairy tale." It is very strange that require does not work for you. Can the paths be incorrectly specified ?? I will add a question to my favorites in order to see what the problems are for such o_O

    • I hate zamorochki. Oleg, use absolute paths and there will be no problems. But in general according to the description, it seems like require "../db.php"; - Vitaly Kustov
    • hmm ... now it just hangs. Ie does not write errors, but the result does not give ... - oleg_ismaylov
    • go to bed)) morning of the evening ... =) - Vitaly Kustov

    write require_once '.'. DIRECTORY_SEPARATOR. '..'. DIRECTORY_SEPARATOR.'db.php ';

    • Same. Java script stops (hangs?) On the beforeSend line. - oleg_ismaylov
    • Code to the studio - Ale_x
    • data hike is not properly framed) example of filling out the key: oem value: $ ("# d_oem"). val () - Ale_x
    • beforeSend (XMLHttpRequest): The option allows you to set a function to modify the XMLHttpRequest object before it is sent. This option is an ajax event, so to cancel sending a request, you need to return false from the function. Return type: function. You have the contents of this function is not here should probably be - Ale_x
    • Hmmm ... I think it's not java, because if in the php file, put the settings in the database, everything works, and if it doesn’t turn ... - oleg_ismaylov