0

I have a form that works (input data is transferred to Mysql database and redirects back to index.php) in my XAMP local sever but when I copy the files and code to my online hosting my data is uploaded to the database but the program is failing to redirect. Please have a look at my redirect code and let me know of any possible solutions.

// Insert
public function insert($query) {
    $insert_row = $this->link->query($query) or die($this->link->error.__LINE__);
    //Validate Insert
    if($insert_row) {
        header("Location: index.php?msg=".urlencode('Record Added'));
        exit();
    } else {
        die ('Error : ('.$this->link->error.') '.$this->link->error);
    }
}

* This is just my insert function, with a redirect if insert is successful.

nj167252
  • 139
  • 2
  • 14

1 Answers1

0

header("Location: index.php?msg=".urlencode('Record Added'));.

Make sure that you are not echoing out any HTML, or any other sort of text at all, before that statement is reached. Otherwise, your redirect will fail.

Tim
  • 810
  • 9
  • 20