Wednesday, 14 December 2016

Redirect to landing page: header("Location:index.php");

Hi Guys trying to find the mistake page not changing to index.php.



Not Redirecting to landing page everything else works fine.



Record is deleted from db, page with delete yes/no also ok



        // Process delete operation after confirmation

if(isset($_POST["ID"]) && !empty($_POST["ID"])){
// Include config file
require_once 'config.php';

// Prepare a select statement
$sql = "DELETE FROM cv WHERE ID = ?";

if($stmt = mysqli_prepare($link,$sql)){
// Bind variables to the prepared statement as parameters
mysqli_stmt_bind_param($stmt, "i", $param_ID);


// Set parameters
$param_ID = trim($_POST["ID"]);

// Attempt to execute the prepared statement
if(mysqli_stmt_execute($stmt)){
// Records deleted successfully. Redirect to landing page

header('Location:index.php');
exit;



}else{
echo "Oops! Something went wrong. Please try again later.";
}
}

// Close statement
mysqli_stmt_close($stmt);


// Close connection
mysqli_close($link);
} else{
// Check existence of ID parameter
if(empty(trim($_GET["ID"]))){
// URL doesn't contain ID parameter. Redirect to error page
header("location: error.php");
exit();
}


}
?>


Any help would be great.



Warning: Cannot modify header information - headers already sent by (output started at /storage/public_html/crudbd/config.php:31) in /storage/public_html/crudbd/delete.php on line 26

No comments:

Post a Comment

c++ - Does curly brackets matter for empty constructor?

Those brackets declare an empty, inline constructor. In that case, with them, the constructor does exist, it merely does nothing more than t...