我使用两个脚本,一个用于从SQL中删除,另一个用于添加到数据库。使用标题时,从一个脚本刷新数据,而不是从另一个脚本?
我遇到的问题是,在运行添加脚本时,它将刷新即时显示更改的页面。然而,在运行删除脚本时,它不会立即刷新它,似乎它会缓存输出?
如果它确实缓存了它重定向到的输出,为什么一个脚本显示添加而另一个不显示删除?
添加脚本
// Set a URL for the user to be redirected to
$header_URL = "Location: ".WEBURL.DOCROOT."pages/parents-evening/{$_SESSION['status']}/";
// SQL statement using the variables from the user to insert into a specific table
$sql = "INSERT INTO $table ($columns) VALUES ($values);";
// Check that the query was successful
if(mysqli_query($conn, $sql))
{
// Success
// Closes the database connection
mysqli_close($conn);
// Sets the redirect location
header($header_URL);
// Exits the script
exit();
}
else
{
// Fail
// Closes the database connection
mysqli_close($conn);
// Sets the redirect location
header($header_URL);
// Exits the script
exit();
}
删除脚本
// Set a URL for the user to be redirected to
$header_URL = "Location: ".WEBURL.DOCROOT."pages/parents-evening/{$_SESSION['status']}/";
// SQL statement to delete from the table provided where the ID is equal to either the POST or GET value
$sql = "DELETE FROM {$table} WHERE id = {$_POST['delete_id']}{$_GET['delete_id']}";
// Check the query was successful
if(mysqli_query($conn, $sql))
{
// Success
// Closes the database connection
mysqli_close($conn);
// Sets the redirect location
header($header_URL);
// Exits the script
exit();
}
else
{
// Fail
// Closes the database connection
mysqli_close($conn);
// Sets the redirect location
header($header_URL);
// Exits the script
exit();
}
“当我删除它不会” 这并不_what_?你继续说它最终会刷新,所以它没有做什么? –
@PatrickQ我已经重写了我的问题。但是,当一个脚本运行时它会立即刷新,另一个脚本不会立即执行。 –
为什么你有'{$ _POST ['delete_id']} {$ _ GET ['delete_id']}''有特定的原因吗?我只希望其中的一个。你真的应该看看参数绑定。 –