Jump to content

Help This N00b?


mackncheeseyx

Recommended Posts

Hey there (: I'm doing  a resume site for the FBLA club at my highschool. I'm also learning PHP along the way. I'm sure this is pretty obvious, but i'm getting this error, and I cant figure out what it means:

Warning: session_register() [function.session-register]: Cannot send session cache limiter - headers already sent (output started at /home2/bythewa1/public_html/resume/profile.php:5) in /home2/bythewa1/public_html/resume/profile.php on line 7

 

 

Here is my page code:



<? include($root_path.'includes/header.php'); ?>
<? if(!isset($_SESSION['login']))
{
session_register('login, userid, firstname, lastname');
}
if($_GET['logout'] == 'yes')
{
	session_unregister('login');
	session_unregister('userid');
	session_unregister('firstname');
	session_unregister('lastname');
}
//die("In");
if(!$_SESSION['login'] == 0)
{
//	die("Here");
	?>
        	<script language="javascript">
		  window.location =  'http://resume.derekbtw.com/index.php';
            </script>
        <?
}

?>


<!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=utf-8" />
<title>Untitled Document</title>
</head>

<body>
<h1><a href="<?=$_SERVER['PHP_SELF']?>?logout=yes">logout</a></h1>
</body>
</html>

 

Link to comment
https://forums.phpfreaks.com/topic/228747-help-this-n00b/
Share on other sites

session stuff has to be at the very top of your php file. It has to be the very first thing that is read by the server.

 

Move session_register to just after the '<?php' tag, well '<?' in your case.

 

Also to not, session_register is deprecated, meaning it is being phased out of use, you simply use $_SESSION['field_name_here']; now.

Source: http://php.net/manual/en/function.session-register.php.

 

Hope that helps

 

Denno

Link to comment
https://forums.phpfreaks.com/topic/228747-help-this-n00b/#findComment-1179326
Share on other sites

session stuff has to be at the very top of your php file. It has to be the very first thing that is read by the server.

 

Move session_register to just after the '<?php' tag, well '<?' in your case.

 

Also to not, session_register is deprecated, meaning it is being phased out of use, you simply use $_SESSION['field_name_here']; now.

Source: http://php.net/manual/en/function.session-register.php.

 

Hope that helps

 

Denno

 

But I need my header insert at the top of the page..or my login wont work..

Link to comment
https://forums.phpfreaks.com/topic/228747-help-this-n00b/#findComment-1179335
Share on other sites

<!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=utf-8" />
<title>- Student Resume</title>
<link rel="stylesheet" href="http://www.resume.derekbtw.com/stylesheets/default.css" type="text/css" />
</head>
<div id="wrap">
         <div id="header">
	<center><span class="logo">      <a href="http://www.resume.derekbtw.com"><img src="http://resume.derekbtw.com/images/logo.png" height=""/></a>
        <br></span></center>
	<ul id="navigation">
		<li<?=($home ? ' class="active"' : '')?>><a href="../index.php" style="text-decoration:none">Home</a></li>
           
           <? if($_SESSION['login'] == 0)
           { ?>
           
           
            <li<?=($register ? ' class="active"' : '')?>><a href="../register.php" style="text-decoration:none">Register</a></li>
           
           <?
	   }
		?>
           
           
           <? if($_SESSION['login'] == 0)
           {

            ?>
            <li<?=($login ? ' class="active"' : '')?>><a href="../login2.php" style="text-decoration:none">Login</a></li>
            
                       <?
	   }
		?>
            
		<li<?=($about ? ' class="active"' : '')?>><a href="../about.php" style="text-decoration:none">About</a></li>
		<li<?=($contact ? ' class="active"' : '')?>><a href="../contact.php" style="text-decoration:none">Contact</a></li>
        	


		<?
		if($_SESSION['login'] == 1)
		{
            ?>    
            	<li<?=($profile ? ' class="active"' : '')?>><a href="../profile.php" style="text-decoration:none">Profile</a></li>
		<?
		}
            ?>	
        </ul>
        </div>		
<div id="content">
    
    <? 
if($_SESSION['login'] == 1)
           {

?>
            
     Welcome, <? print strtoupper($_SESSION['firstname'][0]). substr($_SESSION['firstname'],1, strlen($_SESSION['firstname']));


?>
                                                               

	<?
	   }
?>		

 

 

Thanks guys!

Link to comment
https://forums.phpfreaks.com/topic/228747-help-this-n00b/#findComment-1179403
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.