Нещичко се обърка

Lambenstein

Registered
имам някакъв проблем със старта на сесията. имам следния код в началото на login.php:

Код:
<?
session_start();
ob_start();
include "config.php";
$username = $_SESSION['username'];
?>

и следния код в началото на всяка друга страница:

Код:
<?
session_start();
include "config.php";
$username = $_SESSION['username'];
?>

Питам се, защо става така.
Благодаря предварително.
 
Да знам. ето ти логин страницата:

Код:
<?
session_start();
ob_start();
include "config.php";
$username = $_SESSION['username'];
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
	<title>Log In | Music Day</title>
	<meta name="description" content="Shop powered by PrestaShop" />
	<meta name="keywords" content="shop, prestashop" />
	<meta http-equiv="Content-Type" content="application/xhtml+xml; charset=utf-8" />
	<meta name="generator" content="PrestaShop" />
	<meta name="robots" content="index,follow" />
	<link rel="icon" type="image/vnd.microsoft.icon" href="img/favicon_6F06C92D.ico" />
	<link rel="shortcut icon" type="image/x-icon" href="img/favicon_6F06C92D.ico" />
	<script type="text/javascript">
		var baseDir = 'index.htm';
		var static_token = '29aa0b931751c5bda92454c1d6cfc633';
		var token = 'f7689a68dc6e8026389154704c213eee';
		var priceDisplayPrecision = 2;
		var priceDisplayMethod = 1;
		var roundMode = 2;
	</script>
		<link href="themes/theme219/css/global.css" rel="stylesheet" type="text/css" media="all" />
		<link href="css/jquery.autocomplete.css" rel="stylesheet" type="text/css" media="all" />
			<script type="text/javascript" src="js/jquery/jquery-1.4.4.min.js"></script>
		<script type="text/javascript" src="js/jquery/jquery.easing.1.3.js"></script>
		<script type="text/javascript" src="js/tools.js"></script>
		<script type="text/javascript" src="modules/blockcart/ajax-cart.js"></script>
		<script type="text/javascript" src="themes/theme219/js/tools/treeManagement.js"></script>
		<script type="text/javascript" src="js/jquery/jquery.autocomplete.js"></script>
		
        <style type="text/css">

        </style>
</head>
<body id="index">

<div id="wrapper1">
<div id="wrapper2">
<div id="wrapper3">
	
	<div id="header">
		<a id="header_logo" href="index.htm" title="Music Box">
			<img class="logo" src="themes/theme219/img/logo_6F06C92D.png" alt="Music Box" />
		</a>
		<div id="header_right">
			
<div id="header_user">
<ul>
	<li id="header_user_info">
		<a id="your_account" href="editprofile.php" title="Your Account">Your Account</a><i>|</i>
		<?php 
include "config.php";		
   if ($username) {
?>
<a href="logout.php">Log out</a>
<?php
}
 else {
?>
<a href="login.php">Log in</a><i>|</i>
<a href="register.php">Register</a>
<?php
}
?></li>
	</ul>
</div>



<script type="text/javascript">
	$('ul#first-languages li:not(.selected_language)').css('opacity', 0.3);
	$('ul#first-languages li:not(.selected_language)').hover(function(){
		$(this).css('opacity', 1);
	}, function(){
		$(this).css('opacity', 0.3);
	});
</script>





<div id="search_block_top">
	<form method="get" action="search.php" id="searchbox">
		<label>Search</label>
		<input class="search_query" type="text" id="search_query_top" name="search_query" value="" />
		<a href="javascript:document.getElementById('searchbox').submit();">Go!</a>
		<input type="hidden" name="orderby" value="position" />
		<input type="hidden" name="orderway" value="desc" />
	</form>
</div>
	<script type="text/javascript">
	// <![CDATA[
		
		function tryToCloseInstantSearch() {
			if ($('#old_center_column').length > 0)
			{
				$('#center_column').remove();
				$('#old_center_column').attr('id', 'center_column');
				$('#center_column').show();
				return false;
			}
		}
		instantSearchQueries = new Array();
		function stopInstantSearchQueries(){
			for(i=0;i<instantSearchQueries.length;i++) {
				instantSearchQueries[i].abort();
			}
			instantSearchQueries = new Array();
		}
		$("#search_query_top").keyup(function(){
			if($(this).val().length > 0){
				stopInstantSearchQueries();
				instantSearchQuery = $.ajax({
				url: 'search.php',
				data: 'instantSearch=1&id_lang=1&q='+$(this).val(),
				dataType: 'html',
				success: function(data){
					if($("#search_query_top").val().length > 0)
					{
						tryToCloseInstantSearch();
						$('#center_column').attr('id', 'old_center_column');
						$('#old_center_column').after('<div id="center_column" class="center_column instant_search_results">'+data+'</div>');
						$('#old_center_column').hide();
						$("#instant_search_results a.close").click(function() {
							$("#search_query_top").val('');
							return tryToCloseInstantSearch();
						});
						return false;
					}
					else
						tryToCloseInstantSearch();
					}
				});
				instantSearchQueries.push(instantSearchQuery);
			}
			else
				tryToCloseInstantSearch();
		});
	// ]]>
	
	</script>
	<script type="text/javascript">
	// <![CDATA[
	
		$('document').ready( function() {
			$("#search_query_top")
				.autocomplete(
					'search.php', {
						minChars: 3,
						max: 10,
						width: 500,
						selectFirst: false,
						scroll: false,
						dataType: "json",
						formatItem: function(data, i, max, value, term) {
							return value;
						},
						parse: function(data) {
							var mytab = new Array();
							for (var i = 0; i < data.length; i++)
								mytab[mytab.length] = { data: data[i], value: data[i].cname + ' > ' + data[i].pname };
							return mytab;
						},
						extraParams: {
							ajaxSearch: 1,
							id_lang: 1
						}
					}
				)
				.result(function(event, data, formatted) {
					$('#search_query_top').val(data.pname);
					document.location.href = data.product_link;
				})
		});
	
	// ]]>
	</script>
<?php 
include "config.php";		
   if ($username) {
?>
<ul id="header_links">
	<li><a href="index.php" class="active">home</a></li>
	<li><a href="songs.php">songs</a></li>
	<li><a href="albums.php">albums</a></li>
	<li><a href="videos.php">videos</a></li>
	<li><a href="add-songs.php">add songs</a></li>
	<li><a href="add-albums.php">add albums</a></li>
	<li><a href="add-video.php">add video</a></li>	
</ul>
<?php
}
 else {
?>
<ul id="header_links">
	<li><a href="index.php" class="active">home</a></li>
	<li><a href="songs.php">songs</a></li>
	<li><a href="albums.php">albums</a></li>
	<li><a href="video.php">video</a></li>
	<li><a href="users.php">users</a></li>
</ul>
<?php
}
?>

		</div>
	</div>
	<div id="columns">

		<div id="left_column" class="column">


<div id="categories_block_left" class="block">
	<h4>Categories</h4>
	<div class="block_content">
		<ul class="tree dhtml">
		<li><a href="cat.php?id=1">Rock & Alternative</a></li>
                        <li><a href="cat.php?id=2">Pop, Soul, Jazz</a></li>
                        <li><a href="cat.php?id=3">R`n`B</a></li>
                        <li><a href="cat.php?id=4">Dance, House, Electro</a></li>
                        <li><a href="cat.php?id=5">Hip-Hop</a></li>
                        <li><a href="cat.php?id=6">World, Latino, Reggae</a></li>
                        <li><a href="cat.php?id=8">Electronic, D'N'B</a></li>
                        <li><a href="cat.php?id=9">Metal & Hard Rock</a></li>
                        <li><a href="cat.php?id=11">Techno, Trance, Psychedelic</a></li>
						<li><a href="cat.php?id=10">Българска / Bulgarian</a><ul>
						<li ><a href="cat.php?id=7">Поп-фолк / Pop-Folk</a></li>												
                        <li><a href="cat.php?id=14">Народна / BG Folklore</a></li>						
                        <li class="last"><a href="cat.php?id=15">КЬочеци / Belly Dance</a></li>
							</ul></li>
						<li><a href="cat.php?id=12">Surbian</a></li>
                        <li><a href="cat.php?id=13">Greek</a></li>
                        <li><a href="cat.php?id=16">Retro/Disco</a></li>
                        <li><a href="cat.php?id=17">Romanian</a></li>
                        <li><a href="cat.php?id=18">Spanish</a></li>
                        <li><a href="cat.php?id=19">Relax</a></li>
                        <li><a href="cat.php?id=20">Arabian</a></li>
                        <li><a href="cat.php?id=21">Turkish</a></li>
                        <li><a href="cat.php?id=22">Humor</a></li></ul>	
							</ul>
		<script type="text/javascript">
		// <![CDATA[
			// we hide the tree only if JavaScript is activated
			$('div#categories_block_left ul.dhtml').hide();
		// ]]>
		</script>
	</div>
</div>

<script type="text/javascript">
var CUSTOMIZE_TEXTFIELD = 1;
var customizationIdMessage = 'Customization #';
var removingLinkText = 'remove this product from my cart';
</script>


<div id="tmbestsellers" class="block">
	<h4><a href="top-downloads.php">Top sellers</a></h4>
	<div class="block_content ajax_block_product">
							<div class="home_image">

				<a class="product_image" href="http://livedemo00.template-help.com/prestashop_35382/product.php?id_product=1" title="Wolfmother"><img src="http://livedemo00.template-help.com/prestashop_35382/img/p/1-1-home.jpg" alt="Wolfmother" /></a>

			</div>

			<h5><a href="http://livedemo00.template-help.com/prestashop_35382/product.php?id_product=1" title="Wolfmother">Wolfmother</a></h5>

			<span class="price">$549.00</span>

																	</div>
</div>
</div>

		<div id="center_column" class="center_column">

<div class="breadcrumb">
<div class="breadcrumb_inner">
	<a href="index.php" title="return to Home">Home</a><span class="navigation-pipe">></span><span class="navigation_page">Register</span></div>
</div>

<h1>Already Registered?</h1>
<?php
				if($username)
				{
					echo "<center><span style='color:red;'><h4>Грешка</span>!</h4><br />
					Вече сте влязъл в системата.</center>";
				}
				else{
				if($_POST['log'])
				{
					$username2 = $_POST['username'];
					$password = md5($_POST['password']);
					$sql = "SELECT * FROM users WHERE username='$username2'";
					$result = mysql_query($sql) or die ('Не мога да се свържа с таблица USERS');
					$broi = mysql_num_rows($result);
					$row = mysql_fetch_assoc($result);
					$dLogin = time();
					if (($broi) == 0) {
					echo "<br /><br /><center>Няма такъв потребител</center>";
					   }
					   else {
								if ($password == $row[password]) 
								{
									$_SESSION['username'] = $row[username];
									echo "<center><span style='color:green;'><h4>Успешна операция</span>!</h4><br /><center><i>Добре дошъл </i> <b>".$_SESSION['username'];
									echo ". До <strong>3</strong> сек. ще бъдете прехвърлени в началната страница страница.</center>"; 
						header("REFRESH: 3; url=index.php");
								}
								else{
								echo "<br /><br /><center>Грешна парола</center>";
								}
							}
				}
				else{
					?>
					<form action='' method='post' class='std'>
		<p class='required text'>
			<label for='customer_firstname'>Username</label>
			<input title='Write Your Username!' name='username' type='text' />
			<sup>*</sup>
		</p>
		<p class='required password'>
			<label for='passwd'>Password</label>
			<input type='password' title='Write Your Password!' name='password' />
			<sup>*</sup>
		</p>
        <p class='submit'>
	<input type='submit' name='log' value='Register' class='exclusive' />

	</p>
</form>
<?php
				}
					}
					?>
		</div>
		<div class="clearblock"></div>
	</div>
</div>


<div id="footer_wrapper">
		<div id="footer">
			<div id="tmfooterlinks">
	<div>
		<h4>Your Account</h4>
		<ul>
			<li><a href="my-account.php">Your Account</a></li>
			<li><a href="profile.php">Personal Profile</a></li>
			<li><a href="messages.php">Messages</a></li>
			<li><a href="logout.php">Logout</a></li>
		</ul>
	</div>
	<div>
		<h4>Our offers</h4>
		<ul>
			<li><a href="new-uploads.php">New Uploads</a></li>
			<li><a href="top-downloads.php">Top Downloads</a></li>
			<li><a href="top-albums.php">Top Albums</a></li>
			<li><a href="top-users.php">Top Users</a></li>
		</ul>
	</div>
	<div>
		<h4>Information</h4>
		<ul>
			<li><a href="contact-us.php">Contact us</a></li>
			<li><a href="terms-cond.php">Terms and conditions</a></li>
			<li><a href="about-us.php">About us</a></li>
		</ul>
	</div>
	<p>©2011 Powered by <a href="lambenstein-design.co.cc">Lambenstein Design</a>™. All rights reserved</p>
</div>
			
		</div>
	</div>
</div>
</div>
</body>
</html>
 

Back
Горе