W takim razie oto moje pliki:
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
}
?>
menu.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="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Menu</title>
<style type="text/css">
<!--
.style1 {font-size: 36}
-->
</style>
</head>
<body>
<p> </p>
<p> </p>
<p><span class="style1"><a href="index.php?page=witam">Witam na mojej stronie</a></span></p>
<p align="left" class="style1"><a href="index.php?page=strona1">Strona 1</p>
<!-- <p align="left" class="style1"><a href="index.php?page=strona2">Strona 2 </p> -->
<?
if(isset($_SESSION['rights']) && $_SESSION['rights']=='admin')
print '<p align="left" class="style1"><a href="index.php?page=strona2">Admin </p>';
if(isset($_SESSION['rights']) && $_SESSION['rights']=='user')
print '<p align="left" class="style1"><a href="index.php?page=formularz">Formularz </p>';
?>
</body>
</html>
formularz.php - ma byc dostępny po zalogowaniu - właściwie link ma sie pojawic w menu po zalogowaniu
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="Content-Type" content="text/html; charset=iso-8859-1" />
<title>FormularzPHP</title>
</head>
<body>
<?php
echo"Imie:". $_POST['imie']."<br/>";
echo"Nazwisko: ". $_POST['nazwisko']."<br/>";
echo"Kod pocztowy: ". $_POST['kod']."<br/>";
echo"Miasto: ". $_POST['miasto']."<br/>";
echo"Adres: ". $_POST['adres']."<br/>";
echo"Nr. klienta: ". $_POST['nrklienta']."<br/>";
echo"Rodzaj drewna: ". $_POST['drewno']."<br/>";
echo"Kolor obicia: ". $_POST['kolor']."<br/>";
echo"Dodatki: ". $_POST['dodatki']." ".$_POST['szuflady']." ".$_POST['poleczki']." ".$_POST['lampkanocna']."<br/>";
echo"Uwagi: ". $_POST['uwagi'];
?>
<?php
$do_kogo = "Przyjaciel <dominik200@poczta.onet.pl>";
$temat = "Zamówienie lózka";
$wiadomosc = 'Imie i nazwisko: '.$_POST['imie'].' '.$_POST['nazwisko']."\n";
$wiadomosc .= 'kod: '.$_POST['kod']."\n";
$naglowki = "Reply-to: Jacus <dominik32@buzi-buzi.pl>";
$naglowki .= "From: Jacus <jacus2323@buzi-buzi.pl>\n";
$naglowki .= "Cc: archiwum_mailingu322@buzi-buzi.com\n";
$naglowki .= "Bcc: kontrola_mailingu@32232buzi-buzi.com\n";
mail($do_kogo, $temat, $wiadomosc, $naglowki);
?>
</body>
</html>
formularz html który odnosi się do formularz.php
Kod
?php session_start();
if(isset($_SESSION['rights']) && $_SESSION['rights']=='user')
{
?>
......
<form action="index.php?page=formularzPHP" method="post" enctype="multipart/form-data" name="formularzHTML-owy" class="style1" id="formularzPHP">
<table bgcolor="#999999" width="791" border="0" align="center" cellpadding="2" cellspacing="0" id="1">
<tr>
<td colspan="4"></td>
</tr>
<tr>
<td colspan="4"><div align="center">
<h2>Zamawianie łóżka </h2>
</div></td>
</tr>
<tr>
<td colspan="4"><hr size="2" color="#FFFFFF"/></td>
</tr>
<tr>
<td width="11%"><label>
<div align="left">Imie:</div>
</td>
<td width="40%" align="left"><input name="imie" type="text" size="35" />
</td>
<td width="11%"><label>Nazwisko:</label></td>
<td width="38%" align="left"><input name="nazwisko" type="text" size="35" />
.....
<?}?>