How to rebuild a contact form with design

alenguav
Member | 1
+
0
-

Hello,
I would like to rework this form using your framework https://www.kaisercorp.com.pe/contacto.html
however as you can see it is a formated contact form that send the filled information to an email address
So appart of the security validation (to avoid the form to be used to send spam)
I would like to use Mailjet or Sendgrid to send the message, so I was wondering if you have an example
that I can copy and make work in a php 7.3 powered Cpanel hosting.

dakur
Member | 493
+
+1
-

@alenguav I would suggest you to use some content management system such as WordPress which provides these things in few clicks without need to code anything and fits much better the type of your page (personal presentation).

If you insist on using Nette and manual coding, there are multiple things you need to handle:

  • form validation – collects input from user and validates that it is correct, if not show error message
  • form rendering – formats contact form, renders error message
  • antispam – prevents form from being abused by spambots
  • send e-mail using custom mailing service

Using whole framework for a simple contact form is pretty much overkill, you can stick just with single packages and plain PHP.

nette/forms part is made especially for the first point – form validation. It can help you with form rendering as well, but your case is not so simple to use one-line renderer so you will probably need to use custom rendering.

For antispam you can use e.g. Recaptcha, Google has official PHP client google/recaptcha.

About mailjet or sendgrid, there are definitely some API clients as well, e.g. https://github.com/…et-apiv3-php

In content management systems, these things are packed out-of-the-box in the system or can be simply added as a plugin with few clicks.