the Internet Windows Android

Poor Success PHP. Greetings to you, dear friend

from the conversation with a psychologist from Canada Maria Lokumovich, 2006

Living lifetime: Keep directions

ML: Vladimir Lvovich, in the West now the issue of time distribution is increasingly relevant. Life is gaining pace, and man does not always sleep behind him. How to "get sick" over time and while staying by yourself? How do you personally decide the question of self-organization?

VL: The problem you said has a rather solid age. It leads its history, perhaps since the beginning of capitalism, and went on an increase in the growing, and massive character accepted in the first half of the twentieth century. Her name is already as a task having different solutions options - "Time Management".
But the point here is not that life allegedly speeds up its pace, life has flowed, and flows in its direction and at its speed. And the fact that the existence of a modern person is becoming increasingly crushed into small particular particular, each of which claims to be the most significant, the most important and competes with the rest of the greatest. Life has fallen in wholeness, fragmented. Western civilization in which we live, albeit from the side of the pan and we, the Russians, are in a state of existential schizophrenia. A person needs to have time to take a child to school for an hour, make eight calls, getting to work through a car traffic jam, get to the funeral (so far not your own), pay taxes, etc. Are you asking how to keep up with all this? I answer: it's not necessary to chase, it will take care of you yourself, and then catch up and adds ...
And if without jokes, then everything solves the alignment by the degree of true significance: hierarchization. I try to share my affairs on important and urgent - thoroughly distinguish something else. Important cases are rarely urgent, and urgent rarely are important. You can always pause a little and determine what the degree of importance or urgency is this or that case, event, etc. Such a review is worth producing at least a couple of times a day. And it is necessary to adopt in advance as granted that some cases or intentions, some plans will not be implemented, no matter how you strive for it. Surprisingly, but usually what it does not work, subsequently, it turns out and not necessary. In this regard, I even had my own surcharge: what is not done, then for the better. As far as possible, I try to have plans to have as little as possible so that the main affairs is at least. This allows them to be expressed before the commander, keep the "direction of the main blow" in the life. As the poet said: "... We must leave gaps in fate, and not among the papers ...".

Is the internal freedom compatible with the idea of \u200b\u200bearnings?

ML: The second question also concerns the specifics of life in the West. Daily requirements here are so tightly regulated and reinforced that a person is forced to completely obey them, it practically does not have a place for inner freedom. He wakes up with the idea of \u200b\u200bearnings and falls asleep with these thoughts. What you, as a psychologist, working including with the spiritual vertical of a person, would advise those who have already got into this vicious circle, would like to break out of it, but sometimes there is not enough spirit, mental tank? ..

VL: Do you know, and in Russia the vast majority of people fall asleep and wakes up with the idea of \u200b\u200bearnings. Both in China, and in Indonesia, and in Malaysia, and in Australia, humanity is engaged mainly by thoughts about survival and conservation, or an increase in the level of their material life. It is the same as natural how natural the beast wake up and fall asleep with the thought of impregnation. And, speaking by your words, "place for inner freedom" - not there is a place free from worldly worries. The gallery slave may be internally free, as was free to Diogen, and his owner who has nothing to do is remain a slave of its low-lying passions and concerns about those. Internal freedom is not located and does not require any particular time. It is the quality of attitude to life, to matters, to events and to yourself. The space is not physical, but spiritual.

Ml: Could you give an example of this?

VL: It goes to make the cleaning of the room one believing woman. I always admire the way she does: almost imperceptibly, magically easily. I would not say that she loves this her job: it is for her just a means of earnings, survival, but it is internally free from their work. This allows you to make it in good faith, well and beautiful, because her work enters the higher integrity of her life and the soul, permeated this very spiritual vertical.
Specifying that psychologists, and I, among other things, are not the people who can give advice to all occasions, I would wish for those who try to escape from a closed circle of their affairs and worries, not "break out" from it, but simply It is more internally suspended and carefully examined, again inside yourself. In a different way, this is called meditation ... And when such meditation is practiced and enters the conscious habit, then it turns out that one person called, perhaps, not quite successfully: "break into yourself" ...

The worst friend of happiness is success

ML: In recent decades, we have increasingly hearing the word "success." Each person puts its meaning to this word. What does it mean to be successful for you? And what, perhaps, the mechanisms of achieving success did you manage to open during psychological practice?

VL: You really noticed that in the word "success" each invests. I will only add that often unknowingly invests. And, alas, not always yours. Who do we usually consider successful? Schoolchildren studied at the "excellent", a student, ending the university with a red diploma, a young man who quickly making a dizzying career, a girl who comes to marry a millionaire, and also handsome ... a mature man who has reached wealth, glory, honor, successful In the case, which do, be it science, art, entrepreneurship or sports ...
Speaking generally, a successful person in our presentation is the one who sets themselves goals and reaches them. And as opposed to this, the one who sets itself the goals, but cannot achieve them, is called unsuccessful or loser. Either, we think, the goal turned out to be chosen incorrectly, or the person himself did not reach her achievement ... And at the time, it goes without saying that the goals set should be to which all or most, and these are the goals of success external, success In society, in society. Therefore, both those who do not have any such generally accepted goals in front of them, although they themselves can consider themselves more than successful ...

ML: Yes, it is decided to be successful to consider who won the circumstances and earned a lot of money, but for some reason he does not consider someone who defeated their tendency to annoy and pene or their depression, or learned to think creatively.

VL: That's it. Do you think that we are too fixed with the concepts of "success-failure"? This primitive-estimated, five-darling scale is imprinted in our helpless consciousness from early childhood, even before the kindergarten, and to the first class school, our appraisal addiction is already blooming and smells in might ... Traditionally, an excellent student is a successful one, and the duven - a loser, Although in the global sense everything may not be at all ...
Social paradigm This day is such that it is a successful asking us to be unsuccessful, and here this successful dependence owns our souls and minds, and, by the way, is hardly the main barrier to genuine success.

Ml: why?

VL: Just because success dependence, or, let's say flexible, excessive, shrill success does not leave space for inner freedom in the soul. And the internal non-free prevents success. Whatever you do, the inner non-vital leads to the impotence of the soul, and with it often the mind, and the body.

ML: But after all, on the other hand, it is the desire for success that is the main engine, the main motivational motor of most people! That is what makes them overcome laziness and fear, to achieve something, to move and improve it somewhere - how without it?

VL: And why without it - or rather, why exactly without it? .. The concept of such a long time developed in psychology is the optimal level of motivation - heard? .. And about dialectic? .. Dialectics tells us that the basis for finding truth is a dialogue, That is, the clash of at least two different approaches began, principles, - or, using the old terminology, the struggle and unity of opposites. And the optimal level of motivation "desire for success" is such that emancates any degree of laziness and fear, but does not embroider the soul. I do not overshadow the memo on the main thing about the eternal ...
For simplicity, we will briefly consider cases of the most famous success-dependent classes. Athletes are successful dependent, writers and poets are successful dependent, the actors are successful, it can be said even, successful, almost everything ... But look at those who regularly take the first places in sports, for those who are all excellent on stage, on the winners. Practically, each of them is obvious - literally on the face written! - Such is the inner swell: on the one hand, a huge dedication, high motivation for success - but optimally high, not excavating! - And on the other hand, internal freedom, yes, freedom from this very motivation, or, in any case, the lack of slavery in relation to success, oppose some other values, which can be determined and, for example, how human dignity .. .
For those who lose who is inferior to who are not lucky, most often we observe superconductivity with a shortage of internal freedom. Very many hurt lesions of Russian athletes - not only Russian, of course, but Russian especially, because psychological culture we are still explained by this ...
The same in art. Here is a good-friendly-actor goes to the scene - and it can be seen how he affects and fake, as it does not go there ... can not burn into the image - exactly such actors student, clamped, internally engaged in their success as life In the role, Stanislavsky threw his famous terrible "I do not believe" ... This "I don't believe" tells us and our own soul, and the body in famous many provisions, in particular, in bed ...
The classic image of spiritual impotence is the Pushkin Salieri - a typical excellent student-success, unlike internally free Mozart.
The one-centeredness of success without the internal freedom from him likes us to the creature, which groan on one leg instead of standing and walking at least two. When a person is internally free, "the success, more to say, the myth of success does not own hypnotic, does not overstrain, does not roll, and you can safely do everything that will lead to success by itself.

Medicine from successognom

ML: How to get out of the hypnosis of success dependence?

VL: Put other value guidelines within himself into the head of the corner, build new stars to the soul chaise - and follow them, make them up in yourself and get to build in them. To use the psychotechnics of self-adhesion and self-investment, including my tipoplasty ... I wrote a lot about this and continue to write - in applied to a variety of areas of life.

Ml: Yes, and in applied to love adversities in particular, in "Traumatology of Love" and "Family Wars". Only something does not work after reading the wise texts to immediately apply them in practice ...

VL: Still, who said that he would immediately work out? After all, it is not a piece of iron in the computer, it is not a program to rearrange ... However, with reprogramming the path to internal freedom, perhaps it is possible to conventorly compare.
Some major, as they say, the chips are once enough to understand - but not just understand, but to take ... One of the most important such chips for me personally - saming success and happiness. In one fine moment, which, which, deserved eternity, I realized that success is not a friend of happiness, but the enemy, the cunning enemy pretending to other. A successful person cannot be happy. Even if you achieve success, it will be enough, you will envy someone more successful, or it will just become disgusting and boring to live - you will become "victims", examples of thousands. But happiness in itself can lead to success, although it does not need it at all ...
I will not clarify how many years I spent in a humiliating and unfortunate success, I will only say that now, thank God, I live differently. When I live, without thinking, I am successful or not, it is for me a state of success. Of course, I always wanted to achieve a lot to achieve a lot, and earn more, and in many ways to work: I do not consider myself creatively ending ... But my happiness does not require success for yourself, but only admits it as one of the optional ways of life.

ML: Our conversation took an unexpected turnover. But I remember that in your books for the first time I found the concept of "evaluation addiction", introduced by you and psychologically developed; "Success dependency" is obviously also derived from evaluation dependence?

VL: Quite right. Moreover, the evaluation dependence is precisely in relation to success goes to self-esteem, even more cruel in its action.

ML: Albert Einstein somehow said in time: "It's time to replace the ideal for the ideal of ministry." I wanted to ask your comment on these words, you almost gave him ...

VL: Here, by the way, and an example of a person who cannot be called successless, but which has become successful in the highest sense of the word. Successful and on a specific result of their chosen activity and at a higher account. Einstein can be called, perhaps, quite a happy person, it can be seen by his wonderful face, and he died as a happy man - in a dream.
Einstein all his life was absorbed by finding truth. You can seek the truth in different ways, on different fields and roads. Einstein searched for her in the fields of physics - and found. Not all the truth, of course, but her huge piece, unknown earlier. He was absorbed by the ideal ministry - serving the truth. And success in the social sense came to him himself, as a side effect, not necessarily for him. All my life he walked in some ragged shoes, did not like to change clothes ... This is what the outside of life for him was a purely subordinate side of the inner, Sutheva. Although he was not at all some kind of eccentric, an anachore or ascetic.
If we get acquainted with the biographies and the characters of people who have achieved the greatest results in their fields, be it musicians, artists, poets, warlords or even politicians and rulers, then we will make sure that these people were obsessed with just the ideal of success, but the ideal of ministry. Mark Azeri, Peter First, Abraham Lincoln, artist Michelangelo, Menuhin's violinist, Pianist Glenn Guld, Lion Tolstoy, Dante - For the people of this level, their business, and all life, was a similarity of religious ministry, in which a life action is invested by maximum concentration and peace of mind, and the concern for the assessment of his success was left, as they say, on the will of God ... Leaving the fruits of action - this is called yoga ...

ML: And the last question, Vladimir Lvovich. Already personally about you. What thoughts wake up and fall asleep?

VL: I'm so arranged that I fall asleep only after all thoughts leave me, and they are not returning to me without waking up, but later. What a thought will leave the last and comes first, never guess, yes I don't try ...
But that's what I noticed: Everything goes for the better, if we fall asleep, and waking up, you manage to be in the level of some silent feeling gratefully to trust the secret of life, including myself and the secret personally of my fate and the fate of my loved ones, all the expensive people. This could be called a prayer, but the grateful trust that I say does not contain any plea, no request, and how it would take for a given the commission, selling everything that can be prayed.

Greetings to you, dear friend!

"What is the success in life for you ???"

I ask you, think about, stop for a minute.

Well, now let me help you. The fact that is not a success, I wrote in the previous newsletter. These concepts are leaving right away.

Success is a mental harmony.
Success is to be happy.
Success is the realization of itself and disclosure of its potential.
Success is a fullness of life.
Success is to do your favorite thing that you light up and you can do it around the clock.
Success is to pay for others and make this world better, and other people happier
.

Success is inextricably linked with the condition of the soul. Our soul came to this world to enjoy and realize yourself, and we (our mind, our body, our consciousness) must support it in this. When our soul creates and implements yourself, we feel happy. When we feel and see that the creation of our soul and what we do is bringing a lot of benefit to other people, we are feeling bliss. This is what is called success. Success is the fullness of life.

Any realization of the talents of the soul is possible only thanks to other people.. The soul does not create for myself. She creates for others - to help them and make the life of others filled with and transfer them a part of their happiness. A happy person conveys another part of his happiness, an unhappy person transfers his misfortune. Avoid unhappy people!

If all people suddenly disappeat, the implementation of themselves will be impossible - what's the point in writing books, because nobody reads them, what's the point of creating new clothes models, because nobody will wear them, what is the point of building new homes, in which no one will live?

Obviously, this makes no sense.

Here manifests itself double nature of success: the soul creates and implements yourself, and also helps other people become happier.
The most accurate determination of success I could give sound like this: success is the realization of your authentic talents that make our world better, more perfect, and people are happier.

I want you to be deeply realized that people who live only for themselves and collect wealth only for themselves, are unhappy. They collect these wealth in order to fill the spiritual emptiness that was formed as a result of meaningless life. But this emptiness can be filled with only love, bringing the value to other people. The soul is happy when she gives himself without an excess to make this world better. And what is the point in all those wealth that a person gathered when he leaves life, because we are not durable. The soul comes to create value, realize yourself and then returns "home". If it does not create this value, but deals with something else, she feels bad. She feels that he came to this world and does not do what he wants. And the reason for the reason is our mind - he is blinded by "success" in general understanding of this word. He chases the illusory, and when it reaches it, if at all reaches, he understands the meaninglessness of the achieved.

What is success in general understanding?
- Wealth (money, material things)
- Glory, power, popularity
- Status

But look it all comes from the ego. A person wants to feel his significance, but he does not understand that wealth, fame, status is an illusion. They look like sea water, which do not drink how many, never satisfy thirst. Therefore, people all their lives and chase them. They think that I will earn so much money and I will be happy, I will go to the level of income of $ 100,000 a year and then I will be happy, that's when I go to the scene and I will sing I will be happy, I'll get married, so I will have children ... you You can check it out, but I will claim with 100% confidence that you will not be happy. Moreover, your level of happiness will become even less. You are moving away from your calling, and understanding this soul becomes even more unhappy. The more wealth, fame, status you get, the greater the control over life takes the mind and the further the role of the soul is moved. But true happiness comes from the soul!!!

Success is harmony between soul and mind. The role of the mind is that help Soul self-realize.We incorrectly put priorities. The short-lived body and material things we put in the first place, and we put the immortal soul and inexhaustible ruths for the last. The Bible says: "Collect the rich in the sky, not the earth." Our body is a vehicle for the soul. The soul is associated with the highest mind and only she is able to understand what you need for this world. The universe contributes to people who go their own way. It is the least energy cost, and in our world everything flows through the smallest resistance. I always say that success is the normal course of events. Failure is a deviation from the norm. If you are not so successful now, as you want it - then you do not do what they are intended for. The soul and mind are in the disaster. And the more this breakdown, the more unhappy man.

But you do not think that I say that a person does not need material. Very even need. And that's why: when a person has no money, he is forced to go to work and do some kind of "nonsense." A person spends 10 hours a day in order to make money, but making it he does not realize himself. The chef is that man who at the expense of you implements himself. (I say how is happening in most cases. Most people hate their work, but they work because you need money to survive).

Materials create comfort for the soul. Materials seize this world for the soul. The soul is much more pleasant to create masterpieces in places that inspire it. It is much better to draw a picture in the house by the sea, than on the "messenger pit." The soul needs peace and comfort to create. But what could be peace if the family does not have enough money and every day the husband and wife swear on this occasion.

The soul in order to express myself the time. Only after some time created by the soul value can be sold and sold hundreds, and even thousands of times more expensive than a person gets at work. But to create such value you need time. Personally, I needed 5 months to go to some meager income. After 8 months, my site began to generate income on which the poor family would have been able to live. And only after 17 months my site began to generate income, which will already replace revenues with very high-paying work.

It took 17 months to replace work. But now I am free! I am a favorite thing and this is just the beginning. For my dreams there are no restrictions - which means there are no restrictions for me. When you do your business, your income is limited only by your imagination and only. Who at work earns $ 1,000,000 a year? Yes, maybe there are units. But doing his work even did not come.
Material is important, but only in order to meet the needs of living.

I will say honestly: not receiving income, heavier to create and create masterpieces. The mind constantly says: "What you do is good, but for what we will live?". And this question constantly distracts from creativity. He takes out our happiness. In order to turn off this dialogue, your favorite occupation should bring money. Of course, the mind then begins to ask other questions, but the more money brings a favorite thing, the less patients and distracts these questions become.

Often people work at work, earn money, but still have a hobby. What is a hobby?
Hobbies are a lesson for the soul that does not bring income. But why did the hobby turn into work? The happiest people are those who have a hobby work. They are non-stop are engaged in a favorite thing.
Everything that I am talking about work, about money I want to convey two important thoughts to you: 1) the soul and mind should be in harmony
2) Intangible must always stand in the first place

Focus should be only on the intangible! Material attachments as a result. Here are the right life priorities:
happiness -\u003e Health -\u003e Wealth And many people live according to the scheme
wealth-\u003e Health-\u003e Happiness
And what's worse, there are people who live according to the scheme
wealth-\u003e Wealth-\u003e Wealth

It is not surprising that they are not elsewhere. These people have millions, but they have no friends, they have problems in the family. They have problems in relations with people. Because they think that all people who surround them are only because of their money and only. I do not know how you, but I would not want such happiness. When priorities in life are arranged true wealth arises, as a result. It makes no sense to focus on it. High levels of happiness and health inevitably leads to a high level of income.

Materials and our riches can only serve as an addition to our happiness. They cannot serve as a foundation. What is the foundation, we have already discussed above.

New parameter parsing API:This chapter documented the new Zend API parsing parameters, the author Andrei Zmievski. It was introduced between PHP 4.0.6 and 4.1.0.

The analysis of the parameters is the most common and tedious operation. It would be convenient to also have a standardized error check and the message mechanism. Starting with PHP 4.1.0, there is a way to do all this using the new parameter parsing API. It greatly simplifies the process of obtaining parameters, but its lack is that it cannot be used in features waiting for a variable number of parameters. But since most functions are not included in this category, this parsing API is recommended as a new standard method.

The prototype of the parameter parsing function is:

int zend_parse_parameters (int num_args tsrmls_dc, char * type_spec, ...);

The first argument of this function is the number of actually transmitted parameter functions, so ZEND_NUM_ARGS () can be used here. The second parameter must always be a TSRMLS_CC macro. The third argument is a string that specifies the number and types of arguments expected by your function is similar to how the formatting string Printf specifies the number and format of the output values \u200b\u200bwith which it should work. And finally, the other arguments are pointers to variables that must receive values \u200b\u200bfrom parameters.

zend_parse_parameters () It also performs where it is possible, converting types, so that you always receive data in the format that was requested. Any scalar type can be converted to another, but the conversion between complex types (arrays, objects and resources) and scalar types is not allowed.

If the parameter can be successfully obtained and there were no errors during the conversion process, the function will return Success, otherwise - Failure. The function displays informative error messages if the number of parameters received does not match the requested quantity or if the types of type conversion cannot be performed.

Here are some examples of error messages:

Warning! - INI_GET_ALL () Requires at Most 1 Parameter, 2 Given Warning! - WDDX_Deserialize () EXPECTS PARAMETER 1 TO BE STRING, ARRAY GIVEN

Naturally, each error message is accompanied by a file name and a string in which the error occurred.

Here is a complete list of types specifiers:

    s - String / string (with a possible zero amount of bytes) and its length

  • r - resource stored in ZVAL *

    a - Array / Array, stored in ZVAL *

    o - Object / Object (any class), stored in ZVAL *

    O - Object / Object (class specified by the entry of the class), stored in ZVAL *

    z - Current ZVAL *

The following characters also matter in the specifier string:

    | - Indicates that the remaining parameters are optional. The storage variables corresponding to these parameters must be initialized by default by the extension, since they will not be affected by the disassembled function if the parameters are not transmitted.

    / - the disassembly function causes Separate_zval_if_not_ref () For the following parameter for it, to provide a copy of this parameter, unless this is reference.

    The following parameter for it may be specified type or NULL (applied only to A, O, O, R or Z). If the NULL value is transmitted by the user, the storage pointer will be installed in NULL.

It is best to show the operation of this function on the examples:

Please note that in the third example, we transmit 3 to the number of received parameters received instead Zend_num_args (). This allows you to get the smallest number of parameters if our function expects them a variable number. Of course, if you want to work with the rest of the parameters, you must use zend_get_parameters_array_ex () To receive them.

The discerning function has an extended version that has an additional flags argument that controls its operation.

int zend_parase_parameters_ex (int flags, int num_args tsrmls_dc, char * type_spec, ...);

The only flag that currently can be transmitted is zend_parse_params_quiet, which indicates the functions not to output any error messages during the operation. This can be used in features that expect several sets of completely different arguments, but you will have to independently display an error message.

For example, here's how you can get a set of three long or string:

LONG L1, L2, L3; char * s; if (zend_parse_parameters_ex (ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS () TSRMLS_CC, "lll", & l1, & l2, & l3) \u003d\u003d SUCCESS) (/ * Work with long * /) else if (zend_parse_parameters_ex (ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS (), "s", & s , & s_len) \u003d\u003d Success) (/ * Working with String * /) ELSE (PHP_ERROR (E_WARNING, "% S () Takes Either Three Long Values \u200b\u200bor a String As Argument", Get_Active_Function_Name (TSRMLS_C)); Return;)

With the help of the methods of obtaining parameters, the function you had to get a good idea about this process. For more examples, see the source extension code that are supplied with PHP - they illustrate each submitted case.

Way of Success


By the time of acquiring sufficient independence, the personality is largely already a certain environment during its formation ,. In some cases, it specializes so much, narrows the range of opportunities, which will not allow someone who has formed at the lowest level, to be not only in the highest, but even in the second level of personal opportunities (which were conventionally mentioned above). Of course, such an impact on the personality is not excluded that it will be reasonable to change quite strongly, but the most important in the formation of the personality periods of critical development - already behind and such changes will require immeasurably of great efforts, since if you try to teach the young brought up with wolves.

It is worth thinking very well, and whether you are ready to be able to, perhaps absolutely not peculiar to you the path so much that it will be possible to talk about the death of the previous person (see Ego) for the appearance of a new, clumsy. At affordable features, it can be said that the critical period of development and determination of specialization of social sociable recognition fees falls at the age of 20-30 years (and very important components for this components have periods of development - in 15-20 years) and an attempt to change themselves later in a social role Most likely lead to failure.

As for the "losers", - those who are trying, but does not work, then in the model of social interactions "failure" (ie, no compliance of the desired and obtained) is, not counting the forsmagest circumstances, the insufficiency of the skills of establishment of adequate interactions . Skills are formed on the basis of deposits and developed specialized recognitioners in critical periods and are adjusted by life experience in all practical attempts to implement a creatively found behavior

In the era of the modern web, most sites are becoming increasingly interactive. If earlier, to get the updated data, we needed to be updated in a completely page, now there are technologies that allow you to fully load, but only a separate part of it. In turn, it provides convenience to both users and server owners, because for the user the page load will be faster, since only a separate part of the page is loaded, and the server does not need to generate a page and give it to the user. These features are simply implemented using PHP and AJAX.

Today we will analyze a small example for a better understanding of the work concept. Ajax. Sometimes beginners it is difficult to understand how PHP and AJAX interacts with each other, many people are looking for examples of how to validate forms on the fly without rebooting the entire page. I will briefly show you how it is done, so that you can understand the foundations and principles that will allow you to more quickly master other tools in the future and write your own scripts.

You will come up with a small task yourself, we will check the availability of email addresses in the database without rebooting the page using PHP and AJAX. Such an example will demonstrate well as we can interact with the server without rebooting the page in the browser, as well as, this is often used for various validations of custom forms. In the root directory, create 3 files with index.php, email.php, validate.js.

Creating a page

Create a simple page with one form that contains only one email input field.
The syntax of the index.php file

Ajax Tutorial

The easiest way to work with Ajax- Connect the framework jQuery.What actually I did. jQuery.provides us easy to understand and work syntax for sending Ajaxrequests, why not use this advantage?

Create js script

Validate.js file syntax

$ (document) .ready (Function () (var email \u003d ""; $ ("# email"). Keyup (Function () (VAR VALUE \u003d $ (this) .val (); $ .ajax ((Type: "Post", URL: "email.php", Data: "email \u003d" + Value, Success: Function (MSG) (IF (MSG \u003d\u003d "Valid") ($ ("# Message"). HTML (" This email can be used.This email is already busy.");))));)); $ (" # submit "). Click (function () (if (email \u003d\u003d") (Alert ("Please, Puta to All email");) ELSE ( $.ajax ((Type: "Post", url: "email.php", data: "add_email \u003d" + email, success: function (MSG) ($ ("# Message"). HTML (MSG);)) );)));));

PHP handler

This script will receive POST.request from the client, handle it and return the result. Ajaxreads the result and based on it makes a decision.
Email.php file syntax

$ Connection \u003d Mysqli_Connect ("Localhost", "Email", "Email", "Email"); if (ISSET ($ _ post ["email"]) && $ _post ["email"]! \u003d "") ($ email \u003d $ _post ["email"]; $ email \u003d mysqli_real_escape_string ($ connection, $ email); if (! Filter_Var ($ email, filter_validate_email)) (Echo "Invalid";) ELSE ($ SQL \u003d "SELECT ID FROM Email Where Email \u003d" $ email ""; $ result \u003d mysqli_query ($ Connection, $ SQL); if ( mysqli_num_rows ($ result) \u003d\u003d 1) (Echo "Invalid";) ELSE (ECHO "VALID";))) if (ISSET ($ _ post ["add_email"]) && $ _post ["add_email"]! \u003d "" ) ($ email \u003d mysqli_real_escape_string ($ Connection, $ _ post ["add_email"]); $ sql \u003d "INSERT INTO Email (Email) Values \u200b\u200b(" $ email ")"; if (mysqli_query ($ Connection, $ SQL)) ( Echo. Success.";) ELSE (Echo" Error"; } }

In our php script, the most common code that processes the POST query and prints on the page specific text. As a result Ajaxsends a php request script, the script processes it and gives out the result, Ajaxreads the result and changes the page in real time.

AJAX transfers the POST request script through this code section:

$ .ajax ((Type: "Post", URL: "email.php", Data: "email \u003d" + value, success: function (msg) (if (MSG \u003d\u003d "Valid") ($ ("# Message ") .html (" This email can be used."); email \u003d value;) ELSE ($ (" # Message "). HTML (" This email is already busy."); } } });

type - request type, post or get. In our case, POST;
URL - the script address which you send a request;
DATA - data that is transmitted in the query;
Success - What to do as a result of a successful execution of the query. In our case, the function is called;

In the script itself, the availability of Email in the database is performed each time the symbol is inserted into the Email field. In the input processing script corresponds to the section $ ("# email"). Keyup (function () ()); which checks the keystroke in the ID \u003d "Email" field.
As you can see, the code is quite simple and does not require particularly large skills to understand, everything is tied to the keyup event processing - pressing the key, click () - click on the element mouse. Followed by Ajaxrequest and response from the script. Thus, using PHP and AJAX, you can get almost limitless possibilities for creating interactive pages.
This code does not claim to be high-quality, but if you develop, add the right validations at the client and server level, enter CSS, it can be used in your projects.
If you have any questions, do not hesitate, write comments.
I wish you a good day and fast meetings 🙂