传递表单数据用PHP另一页(Pass form data to another page with

2019-07-21 01:23发布

我有我的网页表单并提交时,需要用户到另一个网页在我的网站。 我想通过进入到下一个页面的表单数据,喜欢的东西:

<?php echo $email; ?>

其中$email是用户在表单中输入的电子邮件地址。 究竟如何我做到这一点?

Answer 1:

来完成,最好的办法是使用POST这是超文本传输协议的一个方法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> 

产量

你好“名”!

您的电子邮件是“whatyou@addedonindex.com”。



文章来源: Pass form data to another page with php
标签: php forms