在php中将隐藏字段中的值从一个页面传递到另一个页面

发布于 2024-12-26 07:57:14 字数 105 浏览 5 评论 0原文

我有一个简单的注册表。 我想将一页中输入的值传递到文本字段中的其他页面。 如何在 php.ini 中从下一页传递和访问它

这是我的第一个 php 页面。

提前致谢。

I have a simple registration form.
I want to pass value entered in one page to other in a text field.
how to pass and access it from next page in php.

this is my first php page.

Thanks in advance.

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

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

发布评论

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

评论(3

狼性发作 2025-01-02 07:57:14

您可以在 HTML 中添加隐藏字段并在 PHP 中访问它们:

<input type="hidden" name="myFieldName" value="someValue"/>

然后在 PHP 中:

$val = $_POST['myFieldName'];

如果您要再次输出此内容,您应该使用 htmlspecialchars 或类似的东西来防止注入攻击。

<input type="hidden" name="myFieldName" value="<?=htmlspecialchars($_POST['myFieldName']);?>"/>

You can add hidden fields within HTML and access them in PHP:

<input type="hidden" name="myFieldName" value="someValue"/>

Then in PHP:

$val = $_POST['myFieldName'];

If you're going to ouput this again you should use htmlspecialchars or something similar to prevent injection attacks.

<input type="hidden" name="myFieldName" value="<?=htmlspecialchars($_POST['myFieldName']);?>"/>
╭ゆ眷念 2025-01-02 07:57:14

假设这是页面 A 中的表单输入

<form name="" action="" method=post enctype="multipart/form-data">
<input type="text" name="myvalue" value="">
<input type=submit>
</form>

在页面 B 中

在您想要获取值的页面中放置此代码

         <?PHP
           foreach ($_REQUEST as $key => $value ) {
             $key=(stripslashes($value));
          }
         ?>

<form name="" action="" method=post enctype="multipart/form-data">
<input type="text" name="myvalue" value="<?PHP echo $myvalue" ?>">
<input type=submit>
</form>

这样您就可以使用变量值或将变量值附加到另一个表单中 做您想做的其他事情

Suppose this the form input in page A

<form name="" action="" method=post enctype="multipart/form-data">
<input type="text" name="myvalue" value="">
<input type=submit>
</form>

In page B

In the page you want to get values put this code

         <?PHP
           foreach ($_REQUEST as $key => $value ) {
             $key=(stripslashes($value));
          }
         ?>

<form name="" action="" method=post enctype="multipart/form-data">
<input type="text" name="myvalue" value="<?PHP echo $myvalue" ?>">
<input type=submit>
</form>

So yo can use or attach variable value to another form do what else you want to do

尴尬癌患者 2025-01-02 07:57:14

使用下面的代码,应该对你有帮助。

<form action ="formhandler.php" method ="POST" >
    <input name = "inputfield" />
    <input type="submit" />
</form>

在 formhandler.php 文件中,您需要输入以下代码来获取 inputfiled 的值。

$inputfield = isset($_POST['inputfield'])?$_POST['inputfield']:"";
// now you can do what ever you want with $inputfield value
echo($inputfield);

use following code, that should help you.

<form action ="formhandler.php" method ="POST" >
    <input name = "inputfield" />
    <input type="submit" />
</form>

on formhandler.php file yo need to enter following code to get the value of inputfiled.

$inputfield = isset($_POST['inputfield'])?$_POST['inputfield']:"";
// now you can do what ever you want with $inputfield value
echo($inputfield);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文