Помощ за скрипт

Lambenstein

Registered
ще може ли някой да хвърли едно око на този скрипт, че след логване не иска да ме препраща.
Код:
<?php
				if($username)
				{
					echo "<center><span style='color:red;'><h4>Opss!</span>!</h4><br />
					You are already logged in.</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>Username doesn't exist!</center>";
					   }
					   else {
								if ($password == $row[password]) 
								{
									$_SESSION['username'] = $row[username];
									header("location:index.php");
								}
								else{
								echo "<br /><br /><center><h4>Wrong Password</h4></center>";
								}
							}
				}
				else{
					?>

<form action="" method="post" id="login_form" class="std">
		<fieldset>
			<h3>Already registered ?</h3>
			<p class="text">
				<label for="email">E-mail address</label>
				<input type="text" id="email" name="username" value="" class="account_input" />
			</p>
			<p class="text">
				<label for="passwd">Password</label>
				<input type="password" id="passwd" name="password" value="" class="account_input" />
			</p>
			<p class="submit">
				<input type="hidden" class="hidden" name="back" value="edit-profile.php" />				<input type="submit" id="SubmitLogin" name="log" class="button" value="Log in" />
			</p>
		</fieldset>
	</form>
    <?php
				}
					}
					?>

И благодаря
 
Преди кода, който си дал най-вероятно имаш извеждане на нещо. За да използваш header преди това не трябва да имаш никакъв изход - отвори си лога с грешки и виж дали нямаш нещо по въпроса там.
 
Прегледах изцяло целия скрипт, затова давам целия код.
ако може да помогне някой.
благодаря предварително

Код:
<?
session_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.htm" 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.htm" 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="http://livedemo00.template-help.com/prestashop_35382/best-sales.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="http://livedemo00.template-help.com/prestashop_35382/" title="return to Home">Home</a><span class="navigation-pipe">></span><span class="navigation_page">Login</span></div>
</div>
<script type="text/javascript">
// <![CDATA[
idSelectedCountry = false;
countries = new Array();
countriesNeedIDNumber = new Array();
countriesNeedZipCode = new Array();
$(function(){
	$('.id_state option[value=]').attr('selected', 'selected');
});
//]]>
</script>
<h1>Log in</h1>



<?php
				if($username)
				{
					echo "<center><span style='color:red;'><h4>Opss!</span>!</h4><br />
					You are already logged in.</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>There is no such username!</center>";
					   }
					   else {
								if ($password == $row[password]) 
								{
									$_SESSION['username'] = $row[username];
									echo "url=index.php";
								}
								else{
								echo "<br /><br /><center><h4>Wrong Password</h4></center>";
								}
							}
				}
				else{
					?>
	<form action="" method="post" id="login_form" class="std">
		<fieldset>
			<h3>Already registered ?</h3>
			<p class="text">
				<label for="email">E-mail address</label>
				<input type="text" id="email" name="username" value="" class="account_input" />
			</p>
			<p class="text">
				<label for="passwd">Password</label>
				<input type="password" id="passwd" name="password" value="" class="account_input" />
			</p>
			<p class="submit">
				<input type="hidden" class="hidden" name="back" value="edit-profile.php" />				<input type="submit" id="SubmitLogin" name="log" class="button" value="Log in" />
			</p>
		</fieldset>
	</form>
<div class="clearblock"></div>
			</div>
		<div class="clearblock"></div>
	</div>
</div>
 <?php
				}
					}
					?>


	<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="identity.php">Personal information</a></li>

			<li><a href="addresses.php">Addresses</a></li>

			<li><a href="discount.php">Discount</a></li>

			<li><a href="history.php">Order history</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 Download</a></li>

			<li><a href="specials.php">Specials</a></li>

			<li><a href="manufacturer.php">Manufacturers</a></li>

			<li><a href="supplier.php">Suppliers</a></li>

		</ul>

	</div>

	<div>

		<h4>Information</h4>

		<ul>

			<li><a href="contact-us.php">Contact</a></li>

			<li><a href="terms.php">Terms and conditions</a></li>

			<li><a href="about-us.php">About us</a></li>

		</ul>

	</div>

	<p>©2011 Powered by <a href="http://www.prestashop.com">PrestaShop</a>™. All rights reserved</p>
</div>
			
		</div>
	</div>
</div>
</div>
</body>
</html>
 

Back
Горе