gpt4 book ai didi

php - 如何知道在循环生成的表单中验证了哪种表单

转载 作者:行者123 更新时间:2023-11-29 17:31:36 25 4
gpt4 key购买 nike

这是我编写的代码,用于生成与表中的条目一样多的表单。我想知道单击哪个提交按钮(即哪个确切的表单)来执行一些 SQL 操作。感谢您的帮助!

<?php
require_once 'header.php';
if (!$loggedin) die();
$result = queryMysql("SELECT * FROM audit_requests");
$num_rows = $result->num_rows;
echo "<div class='main'><h3>$num_rows audit requests found!</h3>";
while ($row = $result->fetch_array(MYSQLI_ASSOC))
{
$requester = stripslashes($row['user']);
$audit_request_id = stripslashes($row['audit_request_id']);
echo <<<_END
<form method='post' action='audit_listings.php' enctype='multipart/form-data'>
<span class='text'><br>Audit request number</span>
<input disabled type='text' maxlength='10' name='audit_request_id' value='$audit_request_id'>
<span class='text'><br>Auditee name</span>
<input disabled type='text' maxlength='16' name='user' value='$requester'>
_END;

if (getCategory($user) == 'Auditor')
{
echo "<input type='submit' value='Apply for this audit request'>";
}
echo <<<_END
</form></div><br>
_END;
}
if (isset($_POST['audit_request_id']))
{
$audit_request_id = stripslashes('audit_request_id');
queryMysql("INSERT INTO audit_plan SELECT * FROM audit_requests WHERE audit_request_id='$audit_request_id'");
queryMysql("UPDATE audit_plan SET applicant='$user' WHERE audit_request_id='$audit_request_id'");
queryMysql("INSERT INTO messages VALUES('', 'TrustusChain', '$org_name', '$address', '', '$city'");
}
?>

最佳答案

您可以向表单添加隐藏字段。喜欢:

echo "<input type=\"hidden\" value=\"form_xxx\">"; 

关于php - 如何知道在循环生成的表单中验证了哪种表单,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50583354/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com