在 php 中制作一个表单,保存用户提供的信息,并将其插入另一个可打印页面

发布于 2024-10-10 19:23:36 字数 289 浏览 4 评论 0原文

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

嗨,我的名字是扎克

我正在使用基于 php 的内容管理系统,因此它应该在 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:

Hi, my name is Zach.

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!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

花伊自在美 2024-10-17 19:23:36

假设您有这样的表单:

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

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

您可以使用如下代码从 Preview.php 页面(在本例中您要在其中打印名称)访问 POST 和 GET 数组:

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

Suppose you have this form:

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

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").

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>
背叛残局 2024-10-17 19:23:36

在你的第一页中:

<form action="letter.php" method="get">
<input type="text" name="personsName"></input>
<input type="submit" value="submit">
</form>

然后在 letter.php 中执行以下操作:

<?php
$firstname = $_GET['personsName'];
echo "My Name is" .$firstname;
?>

可以吗? :)

in your first page:

<form action="letter.php" method="get">
<input type="text" name="personsName"></input>
<input type="submit" value="submit">
</form>

Then in letter.php do this:

<?php
$firstname = $_GET['personsName'];
echo "My Name is" .$firstname;
?>

That ok? :)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文