如何通过 url 传递作为参数传递的 php 值,并将其显示在 html 页面中以传递给另一个 php 文件


How to pass php value which is passed as a parameter through url and displaying it in html page to be passed to another php file

我有html文件,其中使用php代码显示一个在url中传递的值,例如:

我通过 url 传递的变量值是"WORKSHOP",变量名称是"eventName"

在php

页面中使用php调用,如下所示:

 <form action="reg_event_validate.php" method="post" id="htmlform" name="htmlform">
    <table  height="80% style="margin-top: 25px; margin-bottom: 60px; background-color:#D9E2F1; border-radius: 5px;" width="650px" align="center">
    <tbody>
    <tr>
    <th colspan="2">
    <?php
    // The value of the variable name is found
    echo "<h3>Event Registration : " . $_GET["name"] . "</h3>";
    ?> 
    </th>

现在我想将该名称(例如:WORKSHOP)值传递给reg_event_validation.php。怎么走。请提出一些解决方案。

尝试使用隐藏的输入字段传递值,如下所示:

<input type="hidden" name="hiddenval" value="<?php echo $_GET["name"]; ?>"

并尝试在表单操作页面中访问此页面,例如

echo $_POST['hiddenval'];

使用隐藏的输入类型

<input type='hidden' name='eventName' value='<?php echo $_GET["name"]; ?>' />

或者,追加为Query String

action="reg_event_validate.php?eventName=<?php echo $_GET["name"]; ?>"

您可以通过两种方式做到这一点。添加隐藏的输入。

<input type="hidden" name="workshop" value="some_value" />

或者,您可以在窗体中追加到操作

<form method="get" action="reg_event_validation.php?workshop=somevalue" name="form">
....