Pytanie początkujacego... SESJA...
: sob mar 29, 2008 4:04 pm
witam, problem brzmi nastepująco: dopiero zaczałem zabawe w php no wiec zrobiłem sobie taka "stronke" w celach edukacyjnych
http://www.eagl2.yoyo.pl/ chcę zrobić sesję ale nie wiem czemu nie wychodzi mi
sprobojcie sie zalogowac nick: a pass: a
to jest moj plik index.php
[php]<?php
<?php
<?php
<center>
<table width = '80%' height = '90%' border ='1'>
<tr>
<td colspan='3' align = 'center' height='15%' style="color: blue">TYTUL </td>
</tr>
<tr>
<td colspan='3' height='5%'><center>
Zarejestroj sie
</center></td>
</tr>
<tr>
<td width = '10%' valign = 'top' style='padding: 10px;'><center>
<a href= 'http://www.eagl2.yoyo.pl/ '>STRONA GLOWNA</a><br><br>
<a href= 'index.php?1=2'>Artykuly</a><br>
<a href= 'index.php?1=3'>Forum </a><br>
<a href= 'index.php?1=omnie'>O mnie </a><br>
<a href= 'index.php?1=galeria'>Galeria </a><br>
<a href= 'index.php?1=ciekawe'>Ciekawostki </a><br>
<a href= 'index.php?1=4'>Zaloguj sie </a><br>
</center></td>
<td width ='50%' valign ='top' style='padding : 10px;'><center><p style="empty-cells: show">
<?php
$_session['sesja']=1;
if (isset($_GET['1']))
{
$akcja=$_GET['1'];
if (!empty($akcja))
{
if (is_file("$akcja.php"))
include ("$akcja.php");
else
header("Location: http://www.eagl2.yoyo.pl/");
}
else
header("Location: http://www.eagl2.yoyo.pl/");
}
else
echo "Witaj<br> na mojej stronie, jest ona narazie w trakcie budowy, lecz niebawem prace zostana ukonczone";
?>
</center></p></td>
<td width ='10%' valign = 'top' style='padding: 10px;'><center>
Panel uzytkownika <br><br>
<?php
if ($_session['sesja']== 1)
{
echo "<a href= 'index.php?1=profil'>twoj profil</a><br>";
echo "twoje dane<br><br>";
echo "<a href= index.php?akcja=wyloguj>wyloguj</a>";
}
else
echo "nie jestes zalogowany";
?>
</center></td>
</tr>
</table>
</center>
?>
?>
?>[/php]
a to plik sprawdzajacy hasło i nick:
[php]<?php
<html>
<body>
<form action= 'index.php?1=4' method='post' enctype='multipart/form-data'>
<div>
Login: <input type='text' name='login' maxlength='15' size='5' /><br /><br />
Haslo: <input type='password' name='haslo' maxlength='15' size='5' /><br /><br />
<input type='submit' value='zaloguj' />
</div>
</form>
<?php
if ((isset($_POST['login']) && isset($_POST['haslo'])) || ($_session['sesja'] ==1))
{
if ((!empty($_POST['login']) && !empty($_POST['haslo'])) ||($_session['sesja'] ==1 ))
{
if (($_POST['login'] == "a" && $_POST['haslo'] == "a" ) || ($_session['sesja'] ==1))
{
echo "witaj jestes zalogowany jako ".$_POST['login'];
$_session['sesja'] = 1;
echo "co chcesz teraz zrobic??<br><br><a href= 'index.php?1=4'>odswiez<a/><br>";
echo "<a href = '4.php?akcja=wyloguj'>wyloguj sie</a><br>";
}
else
echo "haslo badz login jest bledne";
}
else
echo "pole haslo lub login jest puste";
}
?>
</body>
</html>
?>[/php]
chce zrobic tak ze jesli ktos sie zaloguje to ma widziec panel uzytkownika cały czas nawet jak jest na innych stronach... według mnie jest wszystko dobrze napisane ale jakos nie dizała prosze o pomoc z góry thx
mała poprawka w index.php nie ma byc $_sesion['sesja']=1; to takl napisałem bo cos chciałem sprawdzic
to jest moj plik index.php
[php]<?php
<?php
<?php
<center>
<table width = '80%' height = '90%' border ='1'>
<tr>
<td colspan='3' align = 'center' height='15%' style="color: blue">TYTUL </td>
</tr>
<tr>
<td colspan='3' height='5%'><center>
Zarejestroj sie
</center></td>
</tr>
<tr>
<td width = '10%' valign = 'top' style='padding: 10px;'><center>
<a href= 'http://www.eagl2.yoyo.pl/ '>STRONA GLOWNA</a><br><br>
<a href= 'index.php?1=2'>Artykuly</a><br>
<a href= 'index.php?1=3'>Forum </a><br>
<a href= 'index.php?1=omnie'>O mnie </a><br>
<a href= 'index.php?1=galeria'>Galeria </a><br>
<a href= 'index.php?1=ciekawe'>Ciekawostki </a><br>
<a href= 'index.php?1=4'>Zaloguj sie </a><br>
</center></td>
<td width ='50%' valign ='top' style='padding : 10px;'><center><p style="empty-cells: show">
<?php
$_session['sesja']=1;
if (isset($_GET['1']))
{
$akcja=$_GET['1'];
if (!empty($akcja))
{
if (is_file("$akcja.php"))
include ("$akcja.php");
else
header("Location: http://www.eagl2.yoyo.pl/");
}
else
header("Location: http://www.eagl2.yoyo.pl/");
}
else
echo "Witaj<br> na mojej stronie, jest ona narazie w trakcie budowy, lecz niebawem prace zostana ukonczone";
?>
</center></p></td>
<td width ='10%' valign = 'top' style='padding: 10px;'><center>
Panel uzytkownika <br><br>
<?php
if ($_session['sesja']== 1)
{
echo "<a href= 'index.php?1=profil'>twoj profil</a><br>";
echo "twoje dane<br><br>";
echo "<a href= index.php?akcja=wyloguj>wyloguj</a>";
}
else
echo "nie jestes zalogowany";
?>
</center></td>
</tr>
</table>
</center>
?>
?>
?>[/php]
a to plik sprawdzajacy hasło i nick:
[php]<?php
<html>
<body>
<form action= 'index.php?1=4' method='post' enctype='multipart/form-data'>
<div>
Login: <input type='text' name='login' maxlength='15' size='5' /><br /><br />
Haslo: <input type='password' name='haslo' maxlength='15' size='5' /><br /><br />
<input type='submit' value='zaloguj' />
</div>
</form>
<?php
if ((isset($_POST['login']) && isset($_POST['haslo'])) || ($_session['sesja'] ==1))
{
if ((!empty($_POST['login']) && !empty($_POST['haslo'])) ||($_session['sesja'] ==1 ))
{
if (($_POST['login'] == "a" && $_POST['haslo'] == "a" ) || ($_session['sesja'] ==1))
{
echo "witaj jestes zalogowany jako ".$_POST['login'];
$_session['sesja'] = 1;
echo "co chcesz teraz zrobic??<br><br><a href= 'index.php?1=4'>odswiez<a/><br>";
echo "<a href = '4.php?akcja=wyloguj'>wyloguj sie</a><br>";
}
else
echo "haslo badz login jest bledne";
}
else
echo "pole haslo lub login jest puste";
}
?>
</body>
</html>
?>[/php]
chce zrobic tak ze jesli ktos sie zaloguje to ma widziec panel uzytkownika cały czas nawet jak jest na innych stronach... według mnie jest wszystko dobrze napisane ale jakos nie dizała prosze o pomoc z góry thx
mała poprawka w index.php nie ma byc $_sesion['sesja']=1; to takl napisałem bo cos chciałem sprawdzic