We create a feedback form in PHP. Hidden depression: symptoms and signs

There is a common expression: everything that has ever happened should become a book. From time immemorial, people have written down their history - fictional and real, using literary language and describing only dry facts. And the more accessible writing became, the more widely it was used, gaining, century after century, more and more freedom and creative expression.

The word “blog” won’t surprise anyone these days. Everyone seems to be leading them. Some people write often, others less often, but social networks one way or another organize posts, design them and structure them into one whole, be it your personal page or thematic posts in communities. Simply put, if you have a barely active page on a social network, then you can rightfully be considered a writer. But which one?

This is where the most interesting thing lies. Given the fact that many, if not all, write, very few people really know how to write. A whoppingly small number of frequently writing authors think about improving their craft. Not just to write more competently or more interestingly, but to create texts like a professional writer, with full awareness of the meaning of using a great and powerful word. Therefore, we strongly advise those who write regularly to become a real pro. This will not only expand and improve the author’s presentation, but will also little by little raise the general level of writing culture. And this will already be an impressive milestone in new history.

Creative Writing School


Briefly about: l literary workshops Creative Writing School were founded by writer Maya Kucherskaya and philologist Natalya Osipova. The concept of the school is based on creative writing programs used in American and European universities. All workshop developments are unique and created specifically for Creative Writing School.

Courses:“Human gloss: how to write columns for women’s magazines”, “Storytelling: how to write entertainingly?”, “How to write witty? Search for wit: from poetic epigrams to book reviews”, etc.

Duration: from 10 weeks to one-day intensive.

Price: from 4000 rub.

School of editors in the design bureau of Artyom Gorbunov


Briefly about: w Kola puts preparation on stream and gives a ticket to the profession to domestic editors with clear life guidelines. The school's partners provide jobs for the best students. Review and selection of interns takes place during the defense of the final work.

Program: text and editing, typography and layout, interface and information, negotiations and relationships, design and law, management and results.

Duration: y The curriculum consists of three levels and lasts one academic year.

Price: 40,000 rubles / level.

Courses “Punctum”


Briefly about:"P Unctum” is a small free cultural center where various events take place every day: lectures, screenings, seminars, concerts, exhibitions. The main direction is humanitarian knowledge: philosophy, art, culture, languages, music, cinema, as well as workshops where you can learn specific skills: drawing, creating beautiful texts, speaking dead languages, playing the guitar, etc.

Courses:“Workshop of artistic expression: create a hero”, Olga Gavrilina’s express course “Workshop of text: from concept to implementation”, “Landscape with an iron or creative screenwriting as it is.”

Duration: from 1 lesson.

Price: from 2500 rub. class.

Writing-school


Briefly about: " Writing-School.ru School of Writing is aimed at both beginners and established authors - prose writers, poets, screenwriters, playwrights, etc. Currently, the school is under development, but educational materials are already available for study. It is planned to publish both the school’s original courses and courses from other specialists.

Courses: James Patterson: “Lessons in Writing,” “I Want to Become a Writer: A Start,” “Conscious Writing.”

Duration: Courses are conducted online, materials are available on the website.

Price: from 1250 rub. well.

Online courses at Free Publicity School


Briefly about: Free Publicity School conducts online courses and trainings that help realize the inner need of a person - the need to express oneself to the world. Since 2014, we have conducted more than 20 courses, the graduates of which are published in such publications as Forbes, Psychologies, Lifehacker, “Life is Interesting!”, “Happy Parents” and many others.

Courses:“Conscious Writing Course”, “Strong Text”, “I Write a Book Every Day”, “Personal Brand”, etc.

Duration: 10 days.

Price: from 10,000 rub.

Courses at the International Union of Writers


Briefly about: The International Union of Writers (International Union of Writers, Poets, Playwrights and Journalists) is the world's largest organization of professional writers. The union was founded in 1954. Until recently, the organization's headquarters were located in Paris, but currently the main division is located in Moscow.

Program: literary seminars; lectures on the theory of creating a literary work;
introduction to the history of mass literature; the basics of producing a writer (negotiations with the publisher, subtleties and pitfalls when concluding a contract); Copyright; meetings and master classes with invited writers, journalists, representatives of publishing houses, literary critics who review prose in major media.

Duration: 3 months.

Price: Full-time – 71,100 rubles, distance learning – 60,000 rubles. per semester.

One of the most common tasks in practice is the implementation of a feedback form. You mean writing its HTML code, designing it in CSS, creating a PHP script that would process the data received from the user and send it to our mail, writing a JS script that would check the form for the adequacy of the entered data, protecting our brainchild from spam so that our the mailbox did not collapse from bot attacks.

All of the above points will be discussed in our review and commented on in detail.

So, let's start creating a feedback form:

HTML

First of all, we write HTML code, which specifies the fields that the user will fill in. They will be formalized in the future. The form code looks like this:

< form method= "post" action= "mail.php" > < div class = "left" > < label for = "name" >Name: < input maxlength= "30" type= "text" name= "name" /> < label for = "phone" >Telephone: < input maxlength= "30" type= "text" name= "phone" /> < label for = "mail" >E-mail: < input maxlength= "30" type= "text" name= "mail" /> < div class = "right" > < label for = "message" >Message: < textarea rows= "7" cols= "50" name= "message" > < input type= "submit" value= "Send" />

And visually it now looks like this:

I agree, so far everything is ugly and nothing is clear, but we have just begun.

Let's look at the above code in detail:

  • < form method= "post" action= "mail.php" > …


    In order to create a form you need to use the form tag. It is he who determines the beginning and end of the form for the code interpreter. It, like any tag, has a whole set of attributes, but there are only two required for the form to work, these are method (the method of sending a request to the server, post is used as standard for forms) and action (indicates the path to the form handler file, namely in This file will contain a PHP script, which will then send the user-entered values ​​to us by email. In our case, we see that this file is called mail.php and it is located in the same site directory as the page we are considering).
  • < input maxlength= "30" type= "text" name= "name" />


    Next we have inputs. These are actually the form fields themselves into which users will enter the information we need (type="text" indicates that this will be text). The maxlength attribute specifies how many characters the user can enter in a given form field. The most important attribute is name - it specifies the name of a specific field. It is by these names that the PHP script will subsequently process the information entering it. If desired, you can also set the placeholder attribute, which displays text inside the field that disappears when the cursor is placed inside it. One of the problems with placeholder is that it is not supported by some older browsers.
  • < label for = "name" >Name:


    Used if we have abandoned placeholders. A regular field signature, the for attribute tells which specific field this signature refers to. The value indicates the name of the field we are interested in.
  • < textarea rows= "7" cols= "50" name= "message" >


    Just like input, it is intended for the user to enter information, only this time the field is tailored for long messages. Rows specifies the field size in rows, cols in characters. In general, they set the height and width of our field.
  • < input type= "submit" value= "Send" />


    Type="submit" tells us that this is a button for submitting a form, and value specifies the text that will be inside this button.
  • < div class = "right" >


    are used only for further visual design of the form.

CSS

In order for our feedback form to look presentable, it needs to be formatted. To get the following result:

We used this code:

form ( background: #f4f5f7; padding: 20px; ) form . left, form . right ( display: inline- block; vertical- align: top; width: 458px; ) form . right ( padding- left: 20px; ) label ( display: block; font- size: 18px; text- align: center; margin: 10px 0px 0px 0px; ) input, textarea ( border: 1px solid #82858D; padding: 10px; font- size: 16px; width: 436px; ) textarea ( height: 98px; margin- bottom: 32px; ) input[ type= "submit" ] ( width: 200px; float: right; border: none; background: #595B5F; color: #fff; text- transform: uppercase; )

I don’t see the point in describing CSS in detail; I’ll only draw your attention to the key points:

  1. There is no need to write a design for each tag in the form. Try to build your selectors in such a way that you can design all the elements you need in a couple of lines of code.
  2. Do not use unnecessary type tags to break lines and create indentations < br>, < p> etc. CSS with the display: block and margin with padding properties copes well with these tasks. More about why you shouldn't use it < br> in layout in general, you can read in the article Tag br, but is it really necessary? .
  3. You should not use tabular layout for forms. This contradicts the semantics of this tag, and search engines love semantic code. In order to form the visual structure of the document, we only need div tags, and the display properties specified in CSS: inline-block (arranges blocks in a row) and vertical-align: top (prevents them from scattering across the screen), set them to the required height and voila, nothing superfluous and everything is located the way we need.

For those who want to save their time on website design, I can recommend using CSS frameworks when creating websites, especially self-written ones. My choice in this regard is Twitter Bootstrap. You can watch a lesson on how to design forms using it.

PHP

Well, it's time to make our form work.

We go to our root directory of the site and create the mail.php file there, to which we previously specified the path in the action attribute of the form tag.

Ultimately his code will look like this:

Your message has been sent successfully \" javascript: history.back()\" >Go back

" ; if (! empty ($_POST [ "name" ] ) and ! empty ($_POST [ "phone" ] ) and ! empty ($_POST [ "mail" ] ) and ! empty ($_POST [ "message" ] ) ) ( $name = trim (strip_tags ($_POST [ "name" ] ) ) ; $phone = trim (strip_tags ($_POST [ "phone" ] ) ) ; $mail = trim (strip_tags ($_POST [ "mail" ] ) ) ; $message = trim (strip_tags ($_POST [ "message" ] ) ) ; mail (, , "I wrote to you: " . $name ."
His number: " . $phone . "
His mail: " . $mail . "
His message: "
. $message, ) ; echo "Your message has been sent successfully!
You will receive an answer shortly
$back "
; exit ; ) else ( echo ; exit ; ) ?>

You can skip the discussion of the HTML and CSS portions of this document. At its core, this is a regular website page that you can design according to your wishes and needs. Let's look at its most important part - the PHP script for processing the form:

$back = "

\" javascript: history.back()\" >Go back

" ;

With this line we create a link to return to the previous page. Since we don’t know in advance from which page the user will get to this one, this is done using a small JS function. In the future, we will simply access this variable to display it in the places we need.

if (! empty ($_POST [ "name" ] ) and ! empty ($_POST [ "phone" ] ) and ! empty ($_POST [ "mail" ] ) and ! empty ($_POST [ "message" ] ) ) ( //internal part of the handler) else ( echo "To send a message, fill in all fields! $back "; exit ; )

Here we add a form check to ensure that the fields are full. As you guessed, in the $_POST["name"] part, in quotes, we write the value of the name attribute of our inputs.

If all the fields are filled in, then the script will begin to process the data in its internal part, but if at least one field has not been filled in, then a message will be displayed on the user’s screen asking them to fill out all the fields of the form echo “To send a message, fill out all the fields! $back” and a link to return to the previous page that we created with the very first line.

Next we paste into the internal part of the form handler:

$name = trim(strip_tags($_POST["name"])); $phone = trim(strip_tags($_POST["phone"])); $mail = trim(strip_tags($_POST["mail"])); $message = trim(strip_tags($_POST["message"]));

Thus, we cleared the user-entered data from html tags and extra spaces. This allows us to protect ourselves from receiving malicious code in messages sent to us.

The checks can be made more complicated, but this is at your discretion. We have already installed minimal protection on the server side. We will do the rest on the client side using JS.

I don’t recommend completely abandoning form protection on the server side in favor of JS, since, although extremely rare, there are unique ones with JS disabled in the browser.

After cleaning the tags, add sending a message:

mail ( "[email protected]", "Letter from your_site_address", "Wrote to you: " . $name . "
His number: " . $phone . "
His mail: " . $mail . "
His message: "
. $message "Content-type:text/html;charset=windows-1251") ;

It is this line that is responsible for generating and sending the message to us. It is filled out as follows:

  1. [email protected]” – here you insert your email between the quotes
  2. “Letter from your_site_address” is the subject of the message that will be sent to your email. You can write anything here.
  3. "I wrote to you: ".$name." < br /> His number: ".$phone." < br /> His email: ".$mail." < br /> His message: ".$message – we form the message text itself. $name – we insert the information filled in by the user by accessing the fields from the previous step, in quotes we describe what this field means, with the tag < br /> We break the line so that the message as a whole is readable.
  4. Content-type:text/html;charset=windows-1251 - at the end there is an explicit indication of the data type transmitted in the message and its encoding.

IMPORTANT!

The encoding specified in the “head” of the document ( < meta http- equiv= "Content-Type" content= "text/html; charset=windows-1251" /> ), the encoding from the message Content-type:text/html;charset=windows-1251 and in general the encoding of the PHP file must match, otherwise in messages received by mail, “crazy words” will be displayed instead of Russian or English letters.

Many people do not explicitly indicate the encoding of the message being sent, but on some email clients this may cause problems in the future (unreadable emails are sent to the mail), so I recommend specifying it anyway.

Checking the form for adequacy of the entered data

To ensure that users do not inadvertently miss fields and fill out everything correctly, it is worth checking the entered data.

This can be done both in PHP on the server side and in JS on the client side. I use the second option, because this way a person can immediately find out what he did wrong and correct the error without making additional page transitions.

We paste the script code in the same file where we have the HTML part of the form. For our case it will look like this:

< script>function checkForm(form) ( var name = form. name. value; var n = name. match(/ ^[ A- Za- zA- Jaa- z ] * [ A- Za- zA- Jaa- z ] + $/ ) ; if (! n) ( alert( "The name entered is incorrect, please correct the error") ; return false ; ) var phone = form. phone. value; var p = phone. match(/ ^[ 0 - 9 + ] [ 0 - 9 - ] * [ 0 - 9 - ] + $/ ) ; if (! p) ( alert( "Phone number entered incorrectly") ; return false ; ) var mail = form. mail. value; var m = mail . match(/ ^[ A- Za- z0- 9 ] [ A- Za- z0- 9 \. _- ] * [ A- Za- z0- 9 _] *@ ([ A- Za- z0- 9 ] + ([ A- Za- z0- 9 - ] * [ A- Za- z0- 9 ] + ) * \. ) + [ A- Za- z] + $/ ) ; if (! m) ( alert( "The email entered is incorrect, please correct the error") ; return false ; ) return true ; )

Well, now the usual analysis:

For that, so that when you click on the form submit button, we check it We attach the launch of our script to the form tag:

< form method= "post" action= "mail.php" onSubmit= "return checkForm(this)" >

Now let’s take the checklist point by point:


As you can see, such a mini check is written for each of our fields. I highlighted the check for one field in the screenshot with a red square; for other fields it has a similar structure, and if there is a need to add a field or remove it, you can now easily do this.

It would seem that women understand perfectly well that these are conventions: about St. Valentine, and about Clara Zetkin and Rosa Luxemburg, but still they cannot help but wait for confirmation that they are needed, loved, in demand, and not forgotten. And if they don’t receive it, then hello, melancholy and depression. The lack of love has not been filled, the feeling, not always conscious, is something like this: “even today he cannot do something nice,” “even today I don’t feel loved.”

There is general excitement and high spirits all around; at work, green, unopened tulips are centrally given, but this makes it even more painful. As you know, the worst loneliness is loneliness in a crowd. If, for example, a neighbor, a familiar store clerk, or any passerby in general can congratulate you on the New Year, then in mid-February and early March women expect congratulations from men, and precisely from those who occupy an important place in their lives.

But for the male gender, the situation with the word “should” in relationships always fails greatly. It provokes stubbornness, rejection, fear of not living up to expectations, opposition and the question: “Why do I owe something?”

It turns out that if I didn’t congratulate you, I screwed up, and if I congratulated you, it’s still bad

Most of them may well give flowers to their wife or friend just like that, spontaneously buy a gift or respond to a hint about a ring they like... But when something is expected of them, and they are expected demandingly and biasedly, as in an exam, they fall into a stupor.

Further the situation may develop in different ways. For example, a man congratulated, but was late with congratulations (he is in a stupor, it’s difficult for him) - the woman is dissatisfied. The man gave a gift, but did not choose correctly (wise friends make a wish list in advance) - her holiday was spoiled. The man didn’t congratulate him at all - she expressed everything she thought about it, remembering past failed holidays and old grievances.

And finally, the man did everything right: on time, with flowers, with a gift and a kiss, but she reacts something like this: “Well, of course, today is March 8th, it’s mandatory, he had nowhere to go, he didn’t want to run into an open conflict,” “ duty flowers”, “duty perfumes” and the like. It turns out that even if he didn’t congratulate, he made a mistake, and even if he congratulated, it’s still bad.

The fact remains: these holidays, instead of unburdening everyday life, provoke resentment, melancholy and depression

These stories are not from the head, but from practice. Because psychologists have to deal with the consequences of celebrating Valentine’s Day and International Women’s Day, and these consequences occur for clients of both sexes. For some, depression hits in advance, for others after the holiday.

It’s not very clear who has it more difficult: those who are in a relationship, or those who are single, those who are just starting to get to know their partner, or those who have broken up with him, moreover, recently. It's bad for everyone. The fact remains: these holidays, instead of unloading everyday life, provoke resentment, melancholy and depression.

What to do with all this? I suggest playing on Valentine's Day and Women's Day, and not taking them seriously. As you know, Valentine's Day is celebrated with particular enthusiasm in America, where a modest European saint has been turned into another representative of mass, postcard pop culture.

In the USA, this is a real adult holiday. In our country it is popular mainly among children and teenagers. For them, this is the day of notes, and even girlfriends and teachers write notes to each other. And all these rituals look a lot like training in expressing real feelings. And young people are doing the right thing by training, formulating any of their feelings, including sympathy and friendship.

But it is, of course, wrong and even dangerous for neither children, nor even adults, to base their sense of self on such frivolous attributes of a frivolous holiday like “Valentines”. One of the main differences between the Russian mentality and the Western way of thinking is that in the USA there is a very clear guideline towards which all life aspirations are aimed - success, success, external well-being.

In American families, they assure each other several times a day: “I love you.” That's how it is. But that doesn’t make their problems any less.

There are several signs of the American dream come true: a career, money, a family whose members assure each other several times a day: “I love you.” That's how it is. I will only say that this does not make their family problems any less. But many people are forced to give up searching for themselves, following the approved script, so that God forbid they do not earn the stigma of “loser” from society.

So, one of the generally accepted signs of success is the number of congratulations received on February 14th. If there is none, things are completely bad: you couldn’t win sympathy, you couldn’t present yourself correctly and sell yourself! A false approach that could be called funny if an entire nation did not suffer from it.

March 8 is a different story. This is a grand Soviet public holiday, imposed from above, almost forced. A holiday when bosses are congratulated with a large gift, and secretaries with a smaller one, although their social status does not make them less or more women.

It’s time to overcome all these historical imbalances, at least in your mind, and not subject your relationships and your spiritual world to the test of a holiday, not make them dependent on the timeliness and cost of gifts, have a little pity on men who, covered in red spots, are trying to do something Find out from the consultants at the lingerie store.

Let us remember that true love does not wait for a special occasion to be expressed or confirmed. Valentine's Day is not a holiday of love itself, a red heart is not its symbol, because in life love is not a toy. The aesthetics of Valentine's Day is not the aesthetics of love, but the anticipation of it. And March 8 is a holiday not so much of femininity as of the struggle of women for equal rights with men in production and in government bodies.

I highly recommend taking the initiative into your own hands and having fun these days to the fullest. Don’t freeze in an expectant position, but play at love and focus on the joy of expressing your own emotions, and not counting other people’s confessions.

In the chapter “Beshalach”, describing the exit from Egypt, the Torah says: “The children of Israel left free and fearless (“beyad rama” - Hebrew). In Aramaic these words sound like bereish gale. This is exactly how Onkelos interprets them, who two thousand years ago translated the Torah into Aramaic (the spoken language of that time) for those Jews who even then did not understand the holy language. It is surprising that in the word “breish” (letters bet, reish, yud, shin) the sages see an encrypted abbreviation of the name of the Baal Shem Tov - “Rabbi Yisroel ben Sarah”. But let's talk about everything in order...

First of all, we should recall the famous letter of the Baal Shem Tov, in which he mentions his spiritual ascent to the higher worlds. Having entered the palace of Moshiach, the Baal Shem Tov asked him: “When will the master come?” And Mashiach replied: “When your springs (the teachings of Hasidism) overflow.”

Some books also say that in the word “breish” there is an allusion to Rashbi, the author of the Zohar, since it is an abbreviation of the words “Rabbi Shimon bar Yochai”, as well as an allusion to the great Kabbalist Arizal: “Rabbi Yitzchok Ben Shlomo”. The teachings of Rashbi and Arizal thus lead to Liberation. And it is also said in the Zohar that with this book the Jews “will come out of exile in mercy.”

Rashbi and Arizal revealed the inner part of the Torah only for especially exalted people. But only when the inner part of the Torah spreads everywhere - even to places where there seems to be no place for the Divine - then Moshiach will be revealed in the world. This is exactly how Rabbi Yisroel Baal Shem Tov began to reveal the teachings of Hasidism - to all Jews, without any restrictions.

Let us also note that in the Torah everything is expressed with the greatest precision. Even the fact that the allusion to Rashbi and Arizal lies precisely in the translation into Aramaic - the language of the diaspora, that is, exile - carries a deep meaning.

The literal meaning of the Torah speaks of the exodus from Egypt. However, the Egyptian Galut (exile) is the root of all subsequent exiles, and the Torah verse talking about the exodus from Egypt also hints at the future Geula (liberation) that our righteous Moshiach will bring.

In the Aramaic translation this allusion is more clearly visible. The translation of the Torah from the holy language into the language of Galut was done because during the period of exile, not everyone understood the holy language. Thus, the everyday Aramaic language was raised to the heights of the language of the Torah - the unholy became holy. And this is the preparation for the future Geula.

Although during the first Geula - liberation from Egypt - evil was defeated, it still retained its power. Therefore the children of Israel were forced to flee from evil 1: “for the people fled.”

This is not how it will happen after the arrival of Moshiach. It is said about this 2: “And I will remove the spirit of uncleanness from the earth,” since then evil and uncleanness will completely disappear. Therefore, in the future Geula there will be no need to flee: “For you will go out slowly and not run away” 3, in addition, “and all flesh will see...” (that is, even physical flesh) will be able to observe the Divinity with their own eyes, with complete clarity.

Therefore, allusions to the names of Rashbi and Arizal are contained precisely in the Aramaic translation. Their Torah, their teachings became those “springs that overflowed.” Not trying to hide, to escape from the external, everyday, but on the contrary, bringing the holiness of the Torah into the everyday, i.e. “outside”, they brought us closer to the coming Liberation.

On the 10th day of Shevat, Rebbe Rayatz – the previous Rebbe of Chabad – ascended from this world. The abbreviation of his full name - Yosef Yitzchok ben Sholom - is also “breish”! And this is no coincidence.

As has already been said, the revelation of Hasidism to the entire Jewish people, including women and children, without any restrictions, was started by the Baal Shem Tov. He went from village to village, from city to city and expounded the ideas of Hasidism to even the simplest people. This was also the way of Rebbe Rayatz. He expounded the teachings of Hasidism to everyone. Wherever he was: in Leningrad, Warsaw or New York, no matter who stood in front of him: the Hasidim or their opponents, the Rebbe paved the way for the springs of the Baal Shem Tov.

Let us meet the long-awaited Geula, “as in the days of the exodus from the land of Egypt.” As it is written in our Holy Torah: “And Israel saw the great hand (great deed) that the Lord had done... and they believed in the Lord and in Moses...” In other words, for the coming of Moshiach it is not enough to “believe in the Lord”; it is also necessary to “believe in Moshe” - the head of our generation!