用PHP将表单数据传递给另一个页面 [英] Pass form data to another page with php
问题描述
我在我的主页上有一个表单,当它提交时,它会将用户带到我网站上的另一个页面。我希望将输入的表单数据传递到下一页,如下所示:
<?php echo $ email; ?>
其中 $ email
是电子邮件地址用户输入表单。如何完成这项工作?
完成此操作的最佳方法是使用POST,这是一种超文本传输协议 https://developer.mozilla.org/en-US/docs/ Web / HTTP / Methods
index.php $ b
< HTML>
< body>
< form action =site2.phpmethod =post>
名称:< input type =textname =name>
电子邮件地址:< input type =textname =email>
< input type =submit>
< / form>
< / body>
< / html>
site2.php
< html>
< body>
你好<?php echo $ _POST [name]; ?>!<峰; br>
您的邮件是<?php echo $ _POST [mail]; ?取代。
< / body>
< / html>
输出
您好名字!
您的电子邮件地址是whatyou@addedonindex.com。
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?
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 "whatyou@addedonindex.com" .
这篇关于用PHP将表单数据传递给另一个页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!