V
V
vovkka2018-02-27 10:58:37
PHP
vovkka, 2018-02-27 10:58:37

Why isn't the header redirect happening?

Good afternoon. Please tell me what could be the problem:
There is an output file:

<?php
session_start();
require_once "../db.php";
session_destroy();
header("Location: /"); 
?>

there is a database connection file:
<?php
?>

As you can see, there is nothing in it and there are no empty lines. Nothing is displayed in the browser before header.
The bottom line is that when I connect this file, the redirect does not occur. If there is no connection, everything is OK. But I need to work with the base somehow. Why is this happening ? All the best!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
O
Oleg, 2018-02-27
@vovkka

ob_start() - the very first line.
do not close at the end of files ?>
more bytes bom (a sign that the file is in utf) can be up to <?php

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question