<META HTTP-EQUIV=Refresh CONTENT="1; URL=http://stud.ics.p.lodz.pl/~audi/tmp/index"> i wszsytko działa jak należy, tylko ze jak wpisze złe hasło to również strona sie odświeży i pojawi sie strona index.php tylko ze również pojawi mi się Logout - pomimo iż nie jestem zalogowany - jak to zmienić ?
Oto moje pliki :
Loguj_script.php
Kod
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<META HTTP-EQUIV=Refresh CONTENT="1; URL=http://stud.ics.p.lodz.pl/~audi/tmp/index">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>
<body>
<?php session_start();
$login_check = $_POST['login_check'];
$pass_check = $_POST['pass_check'];
$_SESSION['login']=$_POST['login_check'];
$_SESSION['password']=$_POST['pass_check'];
if (!file_exists("users/$login_check.dat")):
echo("B&%23322;&%23281;dne dane");
elseif (file_exists("users/$login_check.dat")):
include("users/$login_check.dat");
if(($_SESSION['login'] == $login_check) && ($_SESSION['password'] == $pass_check)):
$_SESSION['rights'] = $rights;
print $_SESSION['rights'].'<br>';
echo ("witamy\n");
echo $_SESSION['login'];
echo("\nZalogowałeś się!!");
else:
echo("niepoprawny login lub/i haslo");
endif;
endif;
?>
</body>
</html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<META HTTP-EQUIV=Refresh CONTENT="1; URL=http://stud.ics.p.lodz.pl/~audi/tmp/index">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>
<body>
<?php session_start();
$login_check = $_POST['login_check'];
$pass_check = $_POST['pass_check'];
$_SESSION['login']=$_POST['login_check'];
$_SESSION['password']=$_POST['pass_check'];
if (!file_exists("users/$login_check.dat")):
echo("B&%23322;&%23281;dne dane");
elseif (file_exists("users/$login_check.dat")):
include("users/$login_check.dat");
if(($_SESSION['login'] == $login_check) && ($_SESSION['password'] == $pass_check)):
$_SESSION['rights'] = $rights;
print $_SESSION['rights'].'<br>';
echo ("witamy\n");
echo $_SESSION['login'];
echo("\nZalogowałeś się!!");
else:
echo("niepoprawny login lub/i haslo");
endif;
endif;
?>
</body>
</html>
index.php
Kod
<?php session_start();
if(!empty($_GET['page']))
$file = 'include/'.$_GET['page'].'.php';
else $file = 'include/witam.php';
if(isset($_POST['logOut']))
{
unset($_SESSION['login']);
unset($_SESSION['rights']);
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Programowanie aplikacji internetowych</title>
<link href="style/tło.css" rel="stylesheet" type="text/css" />
</head>
<body>
<table width="100%" border="1">
<tfoot><tr><td colspan="2">Politechnika Lódzka 2007</td></tr></tfoot>
<tr>
<td width="15%" height="190"><img src="images/dominik.jpg" width="243" height="211" /></td>
<td width="85%">
<?php (isset($_SESSION['login']))?logOut():loginForm();?>
<div align="center">
<p><strong>POLITECHNIKA ŁÓDZKA</strong></p>
<p>Instytut informatyki </p>
</div></td>
</tr>
<tr>
<td align="top" height="663"><?php include('include/menu.php');?></td>
<td>
<?php
if(file_exists($file))
include($file);
else include('include/error.php');
?>
</td>
</tr>
</table>
</body>
</html>
<?php
function loginForm()
{
?>
<form id="form1" name="form1" method="post" action="index.php?page=loguj_script">
<table width="11%" border="1" align="right" cellpadding="0" cellspacing="0">
<tr>
<td><label>Logowanie:
<input name="login_check" type="text" size="25" class="textarea" />
</label></td>
</tr>
<tr>
<td><label>Haslo:
<input name="pass_check" type="password" size="25" class="textarea" />
</label></td>
</tr>
<tr>
<td><div align="center">
<input type="submit" name="submit" value="Login" />
</div></td>
</tr>
<tr>
<td height="103"><div align="center"><a href="index.php?page=rejestracja_form1">Rejestracja</a></div><div align="center"></div></td>
</tr>
</table>
</form>
<?php
}
function logOut()
{?>
<form id="form1" name="form1" method="post" action="">
<table width="11%" border="1" align="right" cellpadding="0" cellspacing="0">
<tr>
<td>
<input type="submit" name="logOut" value="LogOut" />
</td>
</tr>
</table>
</form>
<?php
}
?>
if(!empty($_GET['page']))
$file = 'include/'.$_GET['page'].'.php';
else $file = 'include/witam.php';
if(isset($_POST['logOut']))
{
unset($_SESSION['login']);
unset($_SESSION['rights']);
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Programowanie aplikacji internetowych</title>
<link href="style/tło.css" rel="stylesheet" type="text/css" />
</head>
<body>
<table width="100%" border="1">
<tfoot><tr><td colspan="2">Politechnika Lódzka 2007</td></tr></tfoot>
<tr>
<td width="15%" height="190"><img src="images/dominik.jpg" width="243" height="211" /></td>
<td width="85%">
<?php (isset($_SESSION['login']))?logOut():loginForm();?>
<div align="center">
<p><strong>POLITECHNIKA ŁÓDZKA</strong></p>
<p>Instytut informatyki </p>
</div></td>
</tr>
<tr>
<td align="top" height="663"><?php include('include/menu.php');?></td>
<td>
<?php
if(file_exists($file))
include($file);
else include('include/error.php');
?>
</td>
</tr>
</table>
</body>
</html>
<?php
function loginForm()
{
?>
<form id="form1" name="form1" method="post" action="index.php?page=loguj_script">
<table width="11%" border="1" align="right" cellpadding="0" cellspacing="0">
<tr>
<td><label>Logowanie:
<input name="login_check" type="text" size="25" class="textarea" />
</label></td>
</tr>
<tr>
<td><label>Haslo:
<input name="pass_check" type="password" size="25" class="textarea" />
</label></td>
</tr>
<tr>
<td><div align="center">
<input type="submit" name="submit" value="Login" />
</div></td>
</tr>
<tr>
<td height="103"><div align="center"><a href="index.php?page=rejestracja_form1">Rejestracja</a></div><div align="center"></div></td>
</tr>
</table>
</form>
<?php
}
function logOut()
{?>
<form id="form1" name="form1" method="post" action="">
<table width="11%" border="1" align="right" cellpadding="0" cellspacing="0">
<tr>
<td>
<input type="submit" name="logOut" value="LogOut" />
</td>
</tr>
</table>
</form>
<?php
}
?>
Pomóżcie - proszę
No to jak - pomożecie
