Save fields from one page to another

0

I have these two pages each with a form, I would like to be able to send the information of the two forms in an email. How do I save the values of the fields nome and numero and send only on page2 along with the other two fields of the form? I want to avoid sending an email first with the information on page1 and then sending another email with the information on page2.

Page1.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>

Page2.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>
    
asked by anonymous 22.02.2016 / 16:23

1 answer

1

In this case you would need to send GET data from page 1 to page 2 and save it in a hidden.

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Titulo</title>
</head>
<script type="text/javascript">

</script>
<body>
<form name="form" method="get" action="pagina2.html">
    Nome:
    <input type="text" name="nome">
    Numero:
    <input type="text" name="numero">
    <input type="submit">
</form>
</body>
</html>

And on page 2

    <head>
        <meta charset="UTF-8">
        <title>Titulo</title>
    </head>
    <?php
        $nome = $_GET['nome'];
        $numero= $_GET['numero']       
...
    ?>
    <body>
    <form name="form" method="post" action="">
        Endereço:
        <input type="text" name="end">
        Bairro:
        <input type="text" name="bairro">
        <input type="hidden" name="nome" <?php echo "value='$nome'"; ?>>
        <input type="hidden" name="numero" <?php echo "value='$numero'"; ?>>
        <input type="submit">
    </form>
    </body>
    </html>

Then just submit form 2 and get $ _POST ["name"] and $ _POST ["number"] from it, which will be typed in form 1.

Detail: If the page contains PHP, it should have a .php extension

Hugs!

    
22.02.2016 / 16:32