0
I have these two pages each with a form, I would like to be able to send in an email the information of the two forms. How do I save field values nome
and numero
and send only on page 2 along with the other two form fields? I want to avoid sending an email with the page information1 first and then sending another email with the page information2.
Pagina1.html :
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Titulo</title>
</head>
<script type="text/javascript">
</script>
<body>
<form name="form" method="post" action="">
Nome:
<input type="text" name="nome">
Numero:
<input type="text" name="numero">
<input type="submit" onclick="window.location.href='pagina2.html';">
</form>
</body>
</html>
Pagina2.html :
<head>
<meta charset="UTF-8">
<title>Titulo</title>
</head>
<?php
$nome = $_POST['nome'];
...
?>
<body>
<form name="form" method="post" action="">
Endereço:
<input type="text" name="end">
Bairro:
<input type="text" name="bairro">
<input type="submit">
</form>
</body>
</html>
At the level of curiosity, there are other ways to do this?
– Bruno Brito
You can do it the way he said, using $_GET, or also $_POST (which would work, but you’d have a problem with the guy updating the page). Another way is by using cookies or Sessions, but if the visitor’s browser does not allow cookies, it will not work. You can also use Javascript so that all fields will be on the same page, and in the same form, then when it passes the first part, the JS hides the fields of the first part and shows the ones of the second part, with this, just make a condition in JS saying that if the visitor is in part 2, the action of the button is to send the form.
– Clayderson Ferreira