我无法获取表单发布变量,然后让我的PDO语句执行删除.我知道变量$得到的[WID]确实在我的表单中存储了正确的值.问题在于将变量从这个表单传递给下面的代码来执行delete语句.我得到的错误是:参数号无效:参数未定义
//这里是php/PDO代码:
if(isset($_POST['remove'])){
$the_WID = $_POST['WID'];
echo "here is the WID" . $the_WID;
$dlt = "DELETE FROM writing WHERE writing.WID = :writing.WID";
$stmtdlt = $dbh->prepare($dlt);
$stmtdlt->bindParam(':writing.WID', $the_WID, PDO::PARAM_INT);
$stmtdlt->execute();
}
Run Code Online (Sandbox Code Playgroud)
//这是表格
<form action="" method="post">
<button type="submit">Delete</button>
<input TYPE="hidden" name="remove" VALUE="<?php $resulting[WID]; ?>">
</form>
Run Code Online (Sandbox Code Playgroud)
$the_WID = $_POST['WID'];应该是$the_WID = $_POST['remove'];.
你需要回应你的价值: value="<?php echo $resulting[WID]; ?>"
从这个问题的答案来看,似乎你不能.在占位符中使用:
BINDCHR = [:] [a-zA-Z0-9 _] +;
您可以使用字母数字+下划线.
将您的PHP更改为:
if(isset($_POST['remove'])){
$the_WID = $_POST['remove'];
echo "here is the WID" . $the_WID;
$dlt = "DELETE FROM writing WHERE writing.WID = :writingWID";
$stmtdlt = $dbh->prepare($dlt);
$stmtdlt->bindParam(':writingWID', $the_WID, PDO::PARAM_INT);
$stmtdlt->execute();
}
Run Code Online (Sandbox Code Playgroud)
和您的HTML表单:
<form action="" method="post">
<button type="submit">Delete</button>
<input type="hidden" name="remove" value="<?php echo $resulting[WID]; ?>">
</form>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
470 次 |
| 最近记录: |