I would like to know how to create a registration system where the user will initially only enter the email, shortly thereafter he will be directed to another page, where he will complete the registration with the already completed email.
I would like to know how to create a registration system where the user will initially only enter the email, shortly thereafter he will be directed to another page, where he will complete the registration with the already completed email.
As a registration question involves many validations etc., I'll just address the basic steps you can use.
It would basically work as follows using 3 pages:
cadastro1.php
The first page where the user only informs the email to go to the cadastro2.php
page. On this page there would be a form such as:
<form method="post" action="cadastro2.php">
<input required type="email" name="email" placeholder="Informe seu e-mail">
<br>
<button>Prosseguir</button>
</form>
cadastro2.php
In this second page you will receive the email informed on the first page via POST. On this page and the third, you must verify that the information has been sent from the previous page; if not, you redirect to the first page, because the user can try to access the page without going through the previous one:
<?php
$email = $_POST['email']; // pego o campo "email" enviado pela primeira página
if(empty($email)){ // verifico se está vazio
header('Location: cadastro1.php'); // se estiver vazio, redireciona para a 1ª página
}
?>
<form method="post" action="cadastro3.php">
<strong>E-mail:</strong> <?php echo $email?>
<input type="hidden" name="email" value="<?php echo $email?>">
...
resto dos campos do formulário
</form>
On this second page you already have the user's email stored in the $email
variable. In the above example you can create a input hidden
and fill it with the email to be sent along with the form.
cadastro3.php
In this last page, you will receive all the fields sent by the form from the page cadastro2.php
and finalize sending the information to the database.
This is just a very basic scheme of how you could do it. Of course there are more efficient and leaner ways for more advanced users. But as your question just wants to know how to send an email from one page to the other, I think this can help you get a sense of how it works.