adhbvklwqdbviabjiawdnbij Posted August 14, 2011 Share Posted August 14, 2011 I want to show de Logout button when $_SESSION['SESS_CATEGORY'] is 3 but i get a error: Parse error: syntax error, unexpected '<' in /home/ibn/public_html/escola/home.php on line 17 <?php if(trim($_SESSION['SESS_CATEGORY']) == '3') { echo <a href="actions/logout.php">Logout</a>; exit(); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/244791-problem-with-_session/ Share on other sites More sharing options...
MasterACE14 Posted August 14, 2011 Share Posted August 14, 2011 change this: echo <a href="actions/logout.php">Logout</a>; to this: echo "<a href=\"actions/logout.php\">Logout</a>"; Need to remember to wrap those quotes around an echo. Quote Link to comment https://forums.phpfreaks.com/topic/244791-problem-with-_session/#findComment-1257388 Share on other sites More sharing options...
adhbvklwqdbviabjiawdnbij Posted August 14, 2011 Author Share Posted August 14, 2011 Worked. Now i`m having another problem when logouting... Warning: Cannot modify header information - headers already sent by (output started at /home/ibn/public_html/escola/actions/logout.php:18) in /home/ibn/public_html/escola/actions/logout.php on line 19 <?php //Start session session_start(); //Unset the variables stored in session unset($_SESSION['SESS_MEMBER_ID']); unset($_SESSION['SESS_FIRST_NAME']); unset($_SESSION['SESS_CATEGORY']); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Sair</title> <link href="../loginmodule.css" rel="stylesheet" type="text/css" /> </head> <body> <?php header("location: ../index.php"); ?> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/244791-problem-with-_session/#findComment-1257394 Share on other sites More sharing options...
Clarkeez Posted August 14, 2011 Share Posted August 14, 2011 Hi, adhbvklwqdbviabjiawdnbij < lol "Warning: Cannot modify header information - headers already sent" This is because session_start() and header("location: ../index.php"); are both sending header information. Now, header information can only be send once, and must be sent BEFORE anything else is executed or sent to the browser.. Hence why your header() function is causing this error.. I personally use <meta http-equiv="refresh" content="0;URL=YOURURLHERE"/> as an alternative. But be careful, this might not be XHTML valid, but we will work. Quote Link to comment https://forums.phpfreaks.com/topic/244791-problem-with-_session/#findComment-1257400 Share on other sites More sharing options...
MasterACE14 Posted August 14, 2011 Share Posted August 14, 2011 I think you may be using the wrong function... <?php include("../index.php"); ?> I believe that's what you want. Quote Link to comment https://forums.phpfreaks.com/topic/244791-problem-with-_session/#findComment-1257466 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.