0
Guys, I was watching a video lesson here very simple, prof put a code in php in html, I put exactly what it is because and it’s not working at all, I’ve tested in other browsers and tbm didn’t work, I come to think that it is some error of syntax but I do not know where is this error, someone can help me?
Here’s the code:
<?php
session_start();
if($_GET["fechar"]){//pego o fechar do html
$_SESSION["fechar"] = "style='display:none;'";
header("Location: modal.php");//<não funcionou
} else {}
?>
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>Documento sem título</title>
<link type="text/css" rel="stylesheet" href="css/modal.css">
</head>
<body>
<iframe src="http://upinside.com.br" width="100%" height="1820" scrolling="no" frameborder="0"></iframe>
<div id="fundo" <?php echo $_SESSION["fechar"] ?>>
<div class="janela" >
<img src="eu.jpg" title="Eu sou Foda!" alt="minha foto">
<div class="close">
<a href="modal.php?fechar=true" title="fechar">
<img src="RacePortGnome.png" alt="fechar" title="fechar">
</a>
</div><!--close-->
</div><!--janela-->
</div><!--fundo-->
</body>
</html>
According to the teacher, with the header(Location: xxxxx);
this should make the url
page not appear the fechar=true
, but it’s not working at all, does anyone know what I did wrong? Thank you.
EDIT:
Warning: session_start(): Cannot send Session cookie - headers already sent by (output Started at /Applications/MAMP/htdocs/protableless/modal.php:2) in /Applications/MAMP/htdocs/protableless/modal.php on line 4
Warning: session_start(): Cannot send Session cache Limiter - headers already sent (output Started at /Applications/MAMP/htdocs/protableless/modal.php:2) in /Applications/MAMP/htdocs/protableless/modal.php on line 4
Warning: Cannot Modify header information - headers already sent by (output Started at /Applications/MAMP/htdocs/protableless/modal.php:2) in /Applications/MAMP/htdocs/protableless/modal.php on line 8
Ta apparently has something wrong anyway but I have no idea how to fix.
Obs: It’s MAMP because I use mac.
It usually doesn’t work when you have a space or something at the beginning, so confirm if <?php is the first thing in your code, second, you have to put an Exit after header() and switch to Lower case. This would look like header("Location: modal.php"); Exit;
– user1811893
With Exit the site does not even load dps from clicking on the link . -. , the nothing on the <?php and even changing the bid to Lower did not work T-T
– Alexandre Gomes
add
error_reporting(E_ALL);ini_set('display_errors', 1);
at the beginning of the file to display errors, if any is displayed, add to your question– Pedro Sanção