【发布时间】:2021-12-26 17:24:03
【问题描述】:
情况:我有一个成员数据库概述,用户可以在其中单击表中的“更新成员”链接,该链接重定向到显示所单击成员数据的页面。在 url 中,它获取参数 lid.php?lidnummer=4(任何其他 id)。
该页面上有一个表单,允许用户在按下提交按钮后通过create.php 文件向该成员添加电话号码。此页面应重定向回会员页面lid.php?lidnummer=4,并添加了新的电话号码。
我正在通过一个隐藏的表单字段传递 lidnummer,并尝试在 header() 函数中使用它。
header("location: ../lid.php?lidnummer=' . $lidnummer . '");
只有在重定向后 url 才会显示:
lid.php?lidnummer=%27%20.%205%20.%20%27
我在页面上收到“调用成员函数”错误,因为该页面通过一个函数显示成员数据,该函数在按下“更新成员”按钮后通过 $_GET 获取 lidnummer 作为参数。
<?php
if(isset($_GET['lidnummer']))
{
include 'includes/read.php';
$lidnummer = $_GET['lidnummer'];
?>
<div class="contact-form">
<h3>Voeg contactgegevens toe:</h3>
<form action="includes/create.php" method="POST"><b>
<label for="telefoonnummer">
Telefoonnummer:
<input type="text" name="telefoonnummer">
</label>
<input type='hidden' name='lidnummer' value='<?php echo $lidnummer ?>'>
<button type="submit" name='add_telnr'>Voeg telnr toe</button>
</form><br>
<form action="includes/create.php" method="POST">
<label for="email">
Email:
<input type="text" name="email">
</label>
<button type="submit" name='add_email'>Voeg email toe</button></b>
</form><br>
</div>
<div>
<h3>Lid:</h3>
<table>
<tbody>
<tr>
<td>#</td>
<td>Info</td>
<td>Pas aan</td>
<td>Delete</td>
</tr>
<?php show_single_lid($conn, $lidnummer); ?>
</tbody>
</table>
</div>
<?php } ?>
所以我有两个问题:
- 添加电话号码后,如何使用正确的 url 参数 (lidnummer) 让 create.php 文件重定向回 lid.php 页面?
- 我如何(如果解决 1 不能解决此问题)然后再次将 lidnummer 传递给 lid.php 页面以再次显示该成员的数据但已更新?
【问题讨论】: