插入查询执行后重定向不起作用



我一直在尝试在插入数据库后重定向,但它不起作用。插件工作得很好,但它没有重定向这里是我的代码

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");
}

}

最新更新