如何解决插入查询执行后重定向不起作用
我一直在尝试在插入数据库后重定向,但它不起作用。插入工作完美,但它没有重定向这里是我的代码
if (count($errors) == 0) {
$query = "INSERT INTO investment (userid,amount,status,hashID,plan)
VALUES('$uidb','$amount','$status','$id','$plan')";
$results = mysqli_query($db,$query);
if (mysqli_num_rows($results) == 1) {
exit(header('location: https://google.com'));
}else {
array_push($errors,"Invalid Sort Code");
}
}
解决方法
正如@AbraCadaver 和@Lars Stegelitz 评论的那样,试试这个:
但为了更好的安全性,最好使用准备好的语句来做这件事。
if (count($errors) == 0) {
$query = "INSERT INTO investment (userid,amount,status,hashID,plan)
VALUES('$uidb','$amount','$status','$id','$plan')";
$results = mysqli_query($db,$query);
if (mysqli_affected_rows($db)) == 1) {
header('location: https://google.com');
}else {
array_push($errors,"Invalid Sort Code");
}
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。