在 php 中创建一个表单来保存用户提供的信息,并将其插入另一个可打印的页面 [英] Make a form in php that saves information a user gives, and plugs it into a another printable page

查看:30
本文介绍了在 php 中创建一个表单来保存用户提供的信息,并将其插入另一个可打印的页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个网站,该网站可以为网站用户提供预先写好的信件,以便将其发送到某个地方.用户所要做的就是填写表格并点击继续,然后用户在表格中输入的任何信息(例如姓名)都会被插入到可打印页面上的预先写好的信件中.一个基本的例子是,如果表单要求输入姓名,那么你点击继续,在可打印的页面上,它会说:

I'm working on a site that gives the users of the site pre-written letters to send to places. All the user has to do is fill out a form and hit continue, then whatever information the user put into the form (like name for example) gets plugged into a pre-written letter on a printable page. A basic example would be if the form asks for Name then you hit continue, on the printable page, it would say:

我叫扎克.

我使用的是基于 php 的内容管理系统,所以它应该在 php 中.我知道这对于那些知道如何去做的人来说是一件非常简单的事情,不幸的是我不知道.预先感谢您的帮助!

I'm using a php based content management system so it should be in php. I know this is a very simple thing to do for those who know how to do it, I unfortunately don't. Thank you in advance for your help!

推荐答案

假设你有这个表格:

<form action="preview.php" method="POST" >
<input type="text" name="name" />
<input type="submit" value"Print" />
</form>

当您点击提交时,所有字段的值(在本例中为输入,还有 textarea、选择等)将保存到 POST 数组(或 GET,如果您设置了 method="GET").

When you hit submit, the values of all the fields (input in this case, but also textarea, selects, etc) are save to the POST array (or GET if you set method="GET").

您可以使用如下代码从 preview.php 页面(在此示例中您要打印名称的位置)访问 POST 和 GET 数组:

You access the POST and GET arrays from the preview.php page (where you want to print the name in this example) with code like this:

<?php
  $name = $_POST['name'];
?>
<p>Hi, my name is <strong><?=$name?></strong>.</p>

这篇关于在 php 中创建一个表单来保存用户提供的信息,并将其插入另一个可打印的页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆