php - 编辑/更新客户端后,如何重定向到新页面以回显客户端 ID?
问题描述
我想知道是否一些更有经验的 PHP 编码人员可以帮助我解决这个问题:
- 我有一个 edit.php 页面,它显示要在表单字段中更新的当前客户端数据。
- 此时单击的更新按钮只是转到页面clients.php(显示所有客户端数据,包括更新的客户端数据)
- 我的目标是当单击更新按钮而不是作为重定向转到 clients.php 并显示一个充满客户的表格时,我希望它仅重定向到 report.php 页面上的单个客户信息并让它回显当前更新了表中的客户数据。
我得到的只是下面的语法错误。
语法错误,意外的 '' (T_ENCAPSED_AND_WHITESPACE),需要 '-' 或标识符 (T_STRING) 或变量 (T_VARIABLE) 或数字 (T_NUM_STRING)
下面是edit.php页面上的重定向代码,然后是我想要重定向到的reports.php页面下方,但只回显当前客户端ID的数据。
if($run_update){
header("Location: reports.php?cus_id=<?php echo $result['id'] ?>");
keepmsg('<div class="alert alert-success text-center">
<a href="#" class="close" data-dismiss="alert" aria-label="close">×</a>
<strong>Success!</strong> Client updated successfully.
</div>');
} else {
keepmsg('<div class="alert alert-danger text-center">
<a href="#" class="close" data-dismiss="alert" aria-label="close">×</a>
<strong>Sorry!</strong> Client could not be updated.
</div>');
}
下面是简单的reports.php 页面。这是我试图重定向到并仅按 ID 显示当前客户数据
<div class="container">
<div class="jumbotron">
<div class="container">
<div class="row">
<div class="col-md-12">
<small class="pull-right"><a href="edit.php?cus_id=<?php echo $row['id'] ?>" class='btn btn-danger'>Edit Client</a> </small>
<h2 class="text-center invert"> Client Info: <span class="font-weight-light"><?php echo $row['deceased'] ?></span></h2>
<hr>
</div>
</div>
</div>
<br>
<div class="table-responsive table-wrapper">
<table class="table table-bordered table-hover text-center">
<thead>
<tr>
<th class="text-center">Job Type</th>
<th class="text-center">Name of Deceased</th>
<th class="text-center">Plot Number</th>
<th class="text-center">Cemetery</th>
</tr>
</thead>
<tbody class="invert_td">
<tr>
<td><?php echo $row['jobtype'] ?></td>
<td><?php echo $row['deceased'] ?></td>
<td><?php echo $row['plot'] ?></td>
<td><?php echo $row['cemetery'] ?></td>
</tr>
</tbody>
</table>
</div>
</div>
如果有帮助,请在下方,如果我在 edit.php 页面上的表单中的第一行代码
<form class="form-horizontal" role="form" method="post" action="edit.php?cus_id=<?php echo $client_id ?>">
解决方案
嗨 Mohammed 我在我的 functions.php 中有一个函数虽然我不确定这是否是你在标题中传递的意思?
function redirect($page){
header("Location: {$page}{$result} ['id']");
}
我创建了这个函数,但它仍然没有带我到正确的客户端信息页面,例如 http://localhost:9090/wmdb/admin/reports.php?cus_id=132
只为
推荐阅读
- python - PyMongo 和 Discord.py 更新对象
- powershell - Powershell中不同Vim模式的不同光标
- plot - 石榴模型.plot()
- visual-studio-2019 - 在“Windows Server 2019 Datacenter”上使用 Microsoft.VisualStudio.TestTools 时是否存在任何已知问题
- c++ - 如何在STM32F429 TOUCHGFX的ScreenView页面中添加循环和延迟?
- angular - 如何在使用 Angular 服务的 REST 中处理嵌套对象
- javascript - Particle JS - 覆盖整个页面
- mysql - 无法通过套接字连接到本地 SQL 服务器,在 MacOS 中使用 PopSQL
- java - “bamboo-java-specs” java 没有以编程方式创建 docker 映像
- operating-system - 浪费了多少 CPU 时间?(现代操作系统,第 4 版)