katsele
katsele

Reputation: 75

Redirection via header doesn't work

Here's my code:

<?php
include("conf.php"); 
if(isset($_POST['firstName']) && !empty($_POST['firstName'])) {
    $addQuery = "INSERT INTO members VALUES ('','".$_POST['firstName']."','".$_POST['lastName']."','".$_POST['loyalty']."','".$_POST['citizenType']."','".$_POST['grade']."','".$_POST['status']."')";
    mysqli_query($conn,$addQuery);
    header("Location: index.php"); 
    exit();
} else {
?>

<div class="container">
.
.
.
<?php } ?>

I cannot figure out why it doesn't redirect...

Upvotes: 0

Views: 24

Answers (1)

shawn
shawn

Reputation: 413

Based only on the code in your question, there's something wrong in the conf.php include file. It probably has a carriage return or other output that is preventing the header from operating since there is already output.

Upvotes: 1

Related Questions