繁体   English   中英

如何通过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

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

我通过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">
....

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM