Last Updated:

Feedback Forms in various programming languages

The advantage of this form is that there is no need to put a captcha in it and thereby torture its senders, and not spambots.

Validation of filled fields is carried out by means of jQuery, plus additionally you can add checks in php.

This is what the form looks like:

Form

HTML code of the form:

A little bit about the code:
  • We don't use the tag at all to attract the attention of spambots less. <form>
  • By default, the agreement check mark is enabled so as not to embarrass the visitor with an inactive send button. If you need to do the opposite, then you need to remove from the checkbox , and add it to the send button. More information about this tick can be found here. If you don't need it at all, just remove the checkbox and its label from the code.checked="checked"disabled="disabled"
  • The attribute displays the error text if the field is empty.data-validate
  • If the input field is not required, the class is used instead of . In PHP, you need to remove the validation of this field.no-validate-input-atvalidate-input-at
  • The block is needed to display messages after the server processes the form.result-at
  • A hidden field is needed to indicate the form if it is used on different pages. For example, on the main page it will be one value, and in services another. subject-at

CSS code of the form:

A little bit about the code:
  • If the site does not use the FontAwesome font, then the class should be replaced with a cross or other symbol. And accordingly. remove the font itself .alert-validate::aftercontent: "\f129"content: "\2718"font-family: "FontAwesome"

JS form code (jQuery):

A little bit about the code:
  • /send.php - the path to the file that will send mail.
  • If the field is used only for mail, you need to uncomment the line to check its validity.email-at

PHP form code (send.php):

A little bit about the code:
  • All the main points are described in the code comments
  • Mail, which is listed as the sender, it is better to put your own and put it in the white list of the mailer.
  • I put 1 check for forbidden words, but if there are unwanted letters coming from the form, such checks can be added: put a captcha, block by IP or cookies, etc. How does the word check look like, you can see by writing in the message of the form "offer", "buy" or "promotion".
  • If necessary, the results of these checks can not be shown, but report that the form has been sent, respectively. without sending a letter to the mail.