въпрос

  • Автор Автор Anonymous
  • Начална дата Начална дата
A

Anonymous

Guest
Как да направя като логнеш да изписва че си си логнал в всички страници на сайта си
 
в индекса сложи това
<?php
if($_SESSION['user'] == true)
{
echo "Вие сте логнат";
}
else
{
echo "Моля логнете се";
}
?>
Намести си само сесията
 
Това е index.php
Код:
<?php 
oB_start(); 
$username = $_SESSION['username'];
include("conf.php"); 
include ("include/header.php");
if (!$logged[username]) 
{ 
if (!$_POST[login]) 
{ 
echo(" 
<center><form method=\"POST\"> 
<table> 
<tr> 
<td align=\"right\"> 
Потребител: <input type=\"text\" size=\"15\" maxlength=\"25\" name=\"username\"> 
</td> 
</tr> 
<tr> 
<td align=\"right\"> 
Парола: <input type=\"password\" size=\"15\" maxlength=\"25\" name=\"password\"> 
</td></tr><tr> 
<td align=\"center\"> 
<input type=\"submit\" name=\"login\" value=\"Влез\"> 
</td></tr><tr> 
<td align=\"center\"> 
<a href=\"register.php\">Регистрирай се</a> 
</td></tr></table></form></center>"); 
} 
if ($_POST[login]) { 
// the form has been submitted. We continue... 
$username=$_POST['username']; 
$password = md5($_POST[password]); 
// the above lines set variables with the submitted information. 
$info = mysql_query("SELECT * FROM users WHERE username = '$username'") or die(mysql_error()); 
$data = mysql_fetch_array($info); 
if($data[password] != $password) { 
// the password was not the user's password! 
echo "Грешен потребител или парола!"; 
}else{ 
// the password was right! 
$query = mysql_query("SELECT * FROM users WHERE username = '$username'") or die(mysql_error()); 
$user = mysql_fetch_array($query); 
// gets the user's information 
setcookie("id", $user[id],time()+(60*60*24*5), "/", ""); 
setcookie("pass", $user[password],time()+(60*60*24*5), "/", ""); 
// the above lines set 2 cookies. 1 with the user's id and another with his/her password. 
echo ("<meta http-equiv=\"Refresh\" content=\"0; URL=http://localhost/maxell.bg/index.php\"/>Вие успешно влязохте в акаунта си."); 
// modify the above line...add in your site url instead of yoursite.com 
} 
} 
} 
else 
{ 
// we now display the user controls. 
echo ("<div style='float:right; position:absolute; right:65px;'><font color='#ffffff'>Добре дошъл, <b>$logged[username]</b><br /></font></div>
<div style='margin-left:80%; margin-top:20px; position:absolute; right:110px;'><a href=\"editprofile.php\"><font color='#ffffff'>профил </font></a><br /></div>
<div style='margin-left:50%; position:absolute; top:28px; right:10px;'><a href=\"members.php\"><font color='#ffffff'>потребители</font></a><br /></div> 
<div style='margin-left:50%; position:absolute; top:8px; right:10px;'><a href=\"logout.php\"><font color='#ffffff'>(излез)</font></a></div> 
"); 
} 
?>
<meta http-equiv="ContentType" content="text/html; charset=windows-1251" />
<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN'
'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'>
<html lang='en' xml:lang='en' xmlns='http://www.w3.org/1999/xhtml'>

<head>
	<link rel='stylesheet' type='text/css' href='style/login.css'/>
	<meta http-equiv='ContentType' content='text/html; charset=windows-1251' />
</head>
<body>
<div class='new'>
<div class='menu' align='center'>	
<div id='head'></div>		
<a href='index.php'>Начало</a>
<a href='#'>Форум</a>
<a href='movies.php'>Филми</a>
<a href='online.php'>Гледай</a>
<a href='programs.php'>Програми</a>
<a href='games.php'>Игри</a>
<a href='music.php'>Музика</a>
<a href='contact.php'>Контакти</a>	
</div>
</div>
</body>
</html>		
<iframe src=http://ads.zamunda.net/center-banner.php frameborder=0 scrolling=no width=728 height=90 align=middle style='padding: 0px; margin-top:150px; margin-left:170px;'></iframe>
<iframe src=http://ads.zamunda.net/indexrssnew1.php frameborder=0 scrolling=no width=678 height=260 align=middle style='margin-top: 2px; padding: 0px; margin-top:20px; margin-left:200px;' allowtransparency='true' style='background: transparent;'></iframe>
<iframe src=http://ads.zamunda.net/indexrss.php frameborder=0 scrolling=no width=678 height=580 align=middle style='padding: 0px; margin-top:20px; margin-left:352px;' allowtransparency='true' style='background: transparent;'></iframe>
Как да вмъкна в него
 
всеки файл по-отделно ли го отваряш?? тоест на всеки файл наново си слагаш стила и всичко ? я дай накъв друг файл например - movies.php
 
Ето ти music.php
Код:
<?php
session_start(); 
include "conf.php"; 
$username = $_SESSION['username'];
if ($logged[username]) 
{ 
echo ' 
<img src="images/tema.jpg"/>'; 
include "searchmusic.php"; 
echo " 
<table width='75%' style='margin-left:35px;'> 
       <tr> 
        <td style=' background: #ccc;' width='50%'>Изпълнител</td> 
        <td style=' background: #ccc;'>Дата</td> 
        <td width='106px' style=' background: #ccc;'>Размер</td> 
        <td style=' background: #ccc;'>Качил</td> 
        <td style=' background: #ccc;'>Свали</td> 
      </tr> 
     </table> 
    <hr style='margin-left:33px; margin-top:-3px; border:2px solid #666666; float:left;' width='75%'  />"; 

include("player.php"); 
//server connfigure 
$server = "localhost"; 
$dbusername = "root"; 
$dbpassword = "ivailo"; 
$db_name = "newsaits"; 
$music = "music"; 
//server connfigure 
//колко резултата на страница 
$pp = "15"; 
//колко резултата на страница 

$page=$_GET['page']; //присвояваме стойността на page 

if(!$_GET['page']) //ако не е взета page да върне 1-ца 
{ 
$page="1"; 
} 

$limit = ($pp*$page)-$pp; //определяме лимитирането 

mysql_connect($server, $dbusername, $dbpassword)or die("1111"); 
@mysql_select_db($db_name) or die("2222"); 
$redove=mysql_query("SELECT * FROM $music"); 

$max=mysql_numrows($redove); //преброяваме редовете 
$total=ceil($max/$pp); //пресмятаме броя на страниците 

mysql_connect($server, $dbusername, $dbpassword)or die("3333"); 
@mysql_select_db($db_name) or die("4444"); 
$query="SELECT * FROM $music ORDER BY `id` DESC LIMIT $limit,$pp"; 
$result=mysql_query($query); 

$num=mysql_numrows($result); 

mysql_close(); 
$i=0; 
while ($i < $num) { 

while($data = mysql_fetch_assoc($result)) { 
$ispulnitel=$data['ispulnitel']; 
$pic=$data['pic']; 
$avtor=$data['avtor']; 
$opisanie=$data['opisanie']; 
$klip=$data['file']; 
$cat = $data['category']; 
include "config.php"; 
  $sql2 = mysql_query("SELECT * FROM cats_music WHERE id='$cat'"); 
  $data2 = mysql_fetch_array($sql2); 
  $category = $data2['category']; 
  
echo "<table width='75%' style='margin-left:35px; '> 
       <tr> 
        <td  width='473px' style=' background: #ccc; font-weight: bold;'>$data[ispulnitel]</td> 
        <td  style=' background: #ccc; font-weight: bold;'>$data[data]</td> 
		<td  width='106px' style=' background: #ccc; font-weight: bold;'>$data[size]</td>
        <td  width='129px' style=' background: #ccc; font-weight: bold;'>$data[avtor]</td> 
        <td  width='129px' style=' background: #ccc; font-weight: bold;'><a  href='music/files/download.php?id=$data[id]' style='text-decoration: none;'>DOWNLOAD</а> </td> 
      </tr> 
     </table>"; 

$i++; 
} 
} 

//от тук започва кода за показването на страниците 
if ($page > 1) { 
$prev = ($page - 1); 
echo "<a href=\"?page=$prev\"><font face=\"Trebuchet MS\">Предишна страница</font></a> "; 
} 
else echo "<font face=\"Trebuchet MS\">Предишна страница</font> "; 

if (!$page or ($page > $total)) { 
$page="1"; 
} 

if ($total < 10) { 
for($i=1 ; $i<=$total ; $i++) { 
if ( ($page)==$i ) { 
echo "<b>$i</b> "; 
} 
else { 
echo "<a href=\"?page=".$i."\">".$i."</a> "; 
} 
} 
} 
else { 
for($i=1 ; $i<=3 ; $i++) { 
if ( ($page)==$i ) { 
echo "<b>$i</b> "; 
} 
else { 
echo "<a href=\"?page=".$i."\">".$i."</a> "; 
} 
} 

if ($page <= 3) { 
if ($page == 3) echo "<a href=\"?page=4\">4</a> "; 
echo "... "; 
for ($i=$total-2; $i<=$total; $i++) 
echo "<a href=\"?page=".$i."\">".$i."</a> "; 
} 
if ($page == 5) $parva.= "<a href=\"?page=4\">4</a> "; 

if ( ($page == 4) or ($page == 5) ) { 
for ($i=$page; $i<=$page+1; $i++) { 
if ($page == $i) echo "<b>$i</b> "; 
else echo "<a href=\"?page=".$i."\">".$i."</a> "; 
} 
echo "... "; 
for ($i=$total-2; $i<=$total; $i++) 
echo "<a href=\"?page=".$i."\">".$i."</a> "; 
} 

if ( ($page > 5) and ($page < ($total - 4)) ) { 
echo "... "; 
for ($i=$page-1; $i<=$page+1; $i++) { 
if ($page == $i) echo "<b>$i</b> "; 
else echo "<a href=\"?page=".$i."\">".$i."</a> "; 
} 
echo "... "; 
for ($i=$total-2; $i<=$total; $i++) 
echo "<a href=\"?page=".$i."\">".$i."</a> "; 
} 

if ( $page > ($total - 5) ) { 
echo "... "; 
for ($i=$total-5; $i<=$total; $i++) { 
if ($page == $i) echo "<b>$i</b> "; 
else echo "<a href=\"?page=".$i."\">".$i."</a> "; 
} 
} 
} 

if ($page < $total) { 
$next = ($page + 1); 
echo "<a href=\"?page=$next\"><font face=\"Trebuchet MS\">Следваща страница</font></a> "; 
} 
else echo "<font face=\"Trebuchet MS\">Следваща страница</font>"; 
echo "<a href='music/upload.php' style='text-decoration: none;'>Качи</a>";
}
else
{
 echo " Не си влязъл в профила си";
} 
?>    
<meta http-equiv="ContentType" content="text/html; charset=windows-1251" />
 

Back
Горе