0

So, I'm using this php function to update a database in a site.

public function ativo($id, $ativo) {
        if ($ativo == 0) {
            $data['ATIVO'] = 1;     
        }
        if ($ativo == 1) {
            $data['ATIVO'] = 0;     
        }
        $this->db->where('CLIENTE.idCLIENTE', $id);
        $this->db->update('CLIENTE', $data);
        
        header("Location: -imagine-a-web-address-here");

   }

The problem is, I keep getting a blank page after the db update, so the header() isn't really helping me.

Is there any problem with the code or other function to redirect to the address? Thx for the help.

  • what happens, if you type the link in your browser? (PS: sorry I'm not opening unknown links) – Vickel Dec 29 '20 at 18:56
  • I'd check the advice here: https://stackoverflow.com/a/24928578/7956549 More often than not the problem I've had with these is not putting `exit();` after the redirect. – stevenkellow Dec 29 '20 at 19:02
  • People, thanks for the help. Thing is, I was using a free hosting service then. Once I tried all available methods and failed, I upgraded to a paid one and the header() is working just fine now lol. Thx again. – Elyas Correa Nogueira Jan 01 '21 at 17:57

1 Answers1

0

What is the error you got?

Try this;

header('location:'.$_SERVER['HTTP_REFERER']); or redirect($_SERVER['HTTP_REFERER']);