插入查询执行后重定向不起作用
Redirecting after inserting query execution not working
我一直在尝试在插入数据库后进行重定向,但它不起作用。插入工作正常,但它没有重定向这里是我的代码
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");
}
}
我一直在尝试在插入数据库后进行重定向,但它不起作用。插入工作正常,但它没有重定向这里是我的代码
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");
}
}