You have already said that you have a form, so I will list a simple step-by-step without going into details, this you can easily find here at Sopt or if you have questions you can ask new specific questions. I will do using PHP which is the most common.
1. Database
First you must create a database (can be Mysql, which is quite common) with a table with 5 columns:
id
: is the primary auto-increment column, which only keep telling the number of records as they are entered in the table.
email
: where the user’s email will be stored. (type sweep)
CNPJ
: where the user’s CNPJ will be stored. (type sweep)
token
: where the token (a random single sequence type for each record, as if it were a password, e.g..: Ah2bd5h8Hjs
). PHP itself has native resource to generate this. (type sweep)
dia
: in this field you can store the day the user has registered, then check if he has more than 5 days. (type date or datetime)
2º. Send the form to a PHP file
After completing the form, you will submit it (send) to a PHP file (nome_do_arquivo.php
) via POST (you can even use Ajax). This PHP file will receive the form fields (email and CNPJ) and will save the respective information to the BD (email
, CNPJ
, token
and dia
). Before writing to BD, you must generate the token and take the current date (the email and the CNPJ already comes from the form).
After recording the data in the BD, you will send an email message to the user with a link containing the email and the token, in this model:
http://seusite.com.br/pagina.php?email=email_do_usuario&token=token_que_foi_gerado
3º. Validating
The user will receive the message with the link. By clicking it will be redirected to your site according to the link. On the PHP page where the link leads, you will take the "email" and "token" parameters that are in the link URL and query in the BD if the two belong to the same record. If there is any divergence, it means that the link is invalid, then you can display a message "invalid link" or redirect (this depends on your choice).
If the query to the DB returns that the "email" and the "token" are correct, you do the last check: see if it’s been 5 days. For this you will use the value of the field dia
returned from the BD consultation. For this you will have to use comparison between dates, see if the day that is in the BD table is more than 5 days from the current date. If it’s bigger, it means it’s been 5 days and you can display a message "Time-out" or redirect (at your discretion). But if in the comparison of the dates the difference is up to 5 days, it means that everything is OK and the user can proceed.
Edit: Above I mentioned doing the validation in 2 steps. But you can and even better do in 1 step. In the same query to BD, check at once if the email, token and the day check and have less than 5 days.
In short:
The above scheme is just a superficial catch, and at some points will involve data check etc., but it is not so complicated. I believe that even beginners, with a little research and effort, will be able to do it. Go step-by-step, testing each step until you reach the end point.
ENVIO DO FORM PARA O PHP VALIDAÇÃO DO LINK
↓ ↓
validar email e CNPJ captura os parâmetros
(ver se são válidos) "email" e "token" da URL
↓ ↓ ↓
não são válidos consulta o BD
válidos ↓ ↓ ↓
↓ ↓ inválidos válidos
retorna erro ↓ ↓ ↓
(não faz nada) ↓ retorna erro verifica o dia
↓ (não faz nada) ↓ ↓
gerar token e pegar data ↓ ↓
↓ tem mais de tem menos
gravar no BD 5 dias de 5 dias
↓ ↓ ↓
enviar email com link retorna erro acesso
para o usuário (nega acesso) liberado
↓
FIM
(exibe uma mensagem que
deu tudo certo)
Vc uses php or oq?
– Sam
Html5+css+bootstrap
– JuaN Neres
Without backend language you will not be able to do anything, nor send email.
– Sam
I just need a kind of "step-by-step" of what to do to achieve the goal. Then I run after how to do it, even if I have to learn some language.
– JuaN Neres