The url is not equal as commented on in the question
Note the lines below:
Header:
header("Location:/views/painel.php");
Html
echo "<meta http-equiv='refresh' content='0;URL=views/painel.php' />";
Note that in the header you are adding a / (bar) before the URL. When you add this bar at the beginning, it means that the user will have to be redirected to <raiz-do-projeto>/views/painel.php
Without the slider, you inform that the user must be redirected to part of the current URL + address. Ex:
Imagine that you are in the administration area of the site: https://www.example.com/admin/
When you access with the bar at the beginning (as in header), you are informing the user to be redirected to https://www.example.com/views/painel.php
When you access without the bar at the beginning (as in html), you are informing the user to be redirected to https://www.example.com/admin/views/painel.php
Another error in your code is the echo before the Location.
When you write I printed something with echo, print etc. (or even there are "hidden" characters before the tag opens <?php). The PHP cannot modify information from header.
Avoid posting the image of the code. Post the code itself. [mcve]
– Valdeir Psr
I try but when it’s HTML code it doesn’t appear on the screen when saved
– sol25lua
When pasting the code just select it and press
Ctrl + K– Valdeir Psr
Possible duplicate of Error - "Cannot Modify header information - headers already sent"
– Woss
@Andersoncarloswoss problems are different. In the given question the error is
Cannot modify header. In this question, the error is due to the redirect working as expected in the JS, but not redirect as expected when using thephp– Valdeir Psr
@Valdeirpsr no, the problem is exactly that. The question is that the author omitted from the question the error message that he himself quoted.
– Woss