![](/img/trans.png)
[英]how to pass and use the variables passed through header() in php from 1 file to another
[英]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.