user1543782
user1543782

Reputation: 123

Pass form data to another page with php

I have a form on my homepage and when it is submitted, it takes users to another page on my site. I want to pass the form data entered to the next page, with something like:

<?php echo $email; ?>

Where $email is the email address the user entered into the form. How exactly do I accomplish this?

Upvotes: 11

Views: 129311

Answers (2)

umang changani
umang changani

Reputation: 1

<?php echo $_POST["mail"]; ?>.
<?php echo $_POST["mail"]; ?>missing syntax
<?php echo $_POST["email"]; ?>right $_POST["email"];

Upvotes: 0

Stepo
Stepo

Reputation: 1056

The best way to accomplish that is to use POST which is a method of Hypertext Transfer Protocol https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods

index.php

<html>
<body>

<form action="site2.php" method="post">
Name: <input type="text" name="name">
Email: <input type="text" name="email">
<input type="submit">
</form>

</body>
</html> 

site2.php

 <html>
 <body>

 Hello <?php echo $_POST["name"]; ?>!<br>
 Your mail is <?php echo $_POST["mail"]; ?>.

 </body>
 </html> 

output

Hello "name" !

Your email is "[email protected]" .

Upvotes: 35

Related Questions