Да не ми показва

haus

Registered
Искам да попитам като напиша например
http://saitami.com/home?a=clips да не ми показва страницата като не съм логнат да ми я показва само като съм логнат а ако не съм веднага да ме препраща към index.php как да го направя?
 
Код:
if $_SESSION['logged'] != 0 {echo "za da polzvate tazi stranica trqbva da ste lognat ili registriran"; } else { koda na stanicata tuk }
мисля че нещо такова
 
Meniak каза:
Код:
session_start();
if (($_SESSION['logged']) === true) {

// Кода на страницата ти

} 
 else 
{
  header('Location: ../index.php');
}

Да но как да го сложа във html-а защото има и много html
 
Това
Код:
session_start(); 
if (($_SESSION['logged']) === true) {

го слагаш в началото на сайта ти за да включи сесията и за да прави проверка дали потребителя е логнат.
След това поставяш кода на страницата ти



Това
Код:
} 
 else 
{ 
  header('Location: ../index.php'); 
}
го поставяш на края на страницара ти
 
Пак не ме разбра
Как ще стане на html-а защоъо аз другите файлове ги инклудвам и те не ме бъркат искам само на home.php как ще стане на един html
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>404 Not Found</title>
</head><body>
<h1>Not Found</h1>
<p>The requested URL /index.php was not found on this server.</p>
<p>Additionally, a 404 Not Found
error was encountered while trying to use an ErrorDocument to handle the request.</p>
<hr>
<address></address>
</body></html>
 
Искаш като напише някои патя до страницата ти ако тои не е логнат да го праща в началната страница ако не се лажа или?.

Код:
<?php
session_start(); 
if (($_SESSION['logged']) === true) { 
?>
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"> 
<html><head> 
<title>404 Not Found</title> 
</head><body> 
<h1>Not Found</h1> 
<p>The requested URL /index.php was not found on this server.</p> 
<p>Additionally, a 404 Not Found 
error was encountered while trying to use an ErrorDocument to handle the request.</p> 
<hr> 
<address></address> 
</body></html>
<?php
} 
 else 
{ 
  header('Location: index.php'); 
}
?>
 
Meniak каза:
Искаш като напише някои патя до страницата ти ако тои не е логнат да го праща в началната страница ако не се лажа или?.

Код:
<?php
session_start(); 
if (($_SESSION['logged']) === true) { 
?>
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"> 
<html><head> 
<title>404 Not Found</title> 
</head><body> 
<h1>Not Found</h1> 
<p>The requested URL /index.php was not found on this server.</p> 
<p>Additionally, a 404 Not Found 
error was encountered while trying to use an ErrorDocument to handle the request.</p> 
<hr> 
<address></address> 
</body></html>
<?php
} 
 else 
{ 
  header('Location: index.php'); 
}
?>

Точно така но като го сложих така года цялата страница изчесва и става бяла
 
Код:
<?php 
if(!$_SESSION[name]){
?>
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>404 Not Found</title>
</head><body>
<h1>Not Found</h1>
<p>The requested URL /index.php was not found on this server.</p>
<p>Additionally, a 404 Not Found
error was encountered while trying to use an ErrorDocument to handle the request.</p>
<hr>
<address></address>
</body></html>
<?php
} else {
header('Location: index.php');
}
?>
 

Back
Горе