Zrobiłem 4 przykładowe pliki związane z logowanie do systemu, walidacja danych przesłanych z logowanie do systemu oraz przykładowa strona po spełnieniu wszystkich możliwych warunków. Dołączyłem także do tego funkcje. Proszę was o trochę cierpliwości i zrozumienia.

index.php
<?php {include('logowanie.php');} else { {include('includes/'.$_GET['url'].'.php');} } ?>
logowanie.php
<html> <head> <title>Logowanie</title> <meta name="AUTHOR" content="A"> <meta http-equiv="Expires" content="0" /> <meta http-equiv="Cache-Control" content="no-store, no-cache, must-revalidate" /> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <style type="text/css"> <!-- #centrowanie{width:80%; min-width:500px; max-width:750px; margin: 0 auto;} td.szerokosc{width:30%; min-width:150px; max-width:2500px;} //--> </style> </head> <body> <form name="logowanie" method="post" action="logowaniedosystemu.php"> <table border="1" id="centrowanie" cellspacing="5" cellpadding="5"> <tr> <td colspan="2"><center>Logowanie do strony internetowej</center></td> </tr> <tr> <td class="szerokosc"><center>Login</center></td> <td><center><input type="text" name="login" required = "required" size="35"></td> </tr> <tr> <td class="szerokosc"><center>Haslo</center></td> <td><center><input type="password" name="haslo" required = "required" size="35"></center></td> </tr> <?php { } ?> <tr> <td colspan="2"><center><input type="submit" name="Wyslij" value="Wyślij"></center></td> </tr> </table> </form> </body> </html>
logowaniedosystemu.php
<?php { include('logowanie.php'); } $walidacja=false; $login=$_POST['login']; $haslo=$_POST['haslo']; if(($login=="")||($login==" ")) { $tablica[]='Brak wpisanego loginu.'; $walidacja=true; } if(($haslo=="")||($haslo==" ")) { $tablica[]='Brak wpisanego hasła'; $walidacja=true; } if($walidacja==true) { include('logowanie.php'); } include('funkcje.php'); $połacz=mysql_connect('localhost', 'root','czyalamakota') or die(blad('Nie można połączyć się z bazą danych')); $zapytanie_id=mysql_query('SELECT * FROM `uzytkownicy` WHERE ((uzytkownicy.login=\''.$login.'\')&&(uzytkownicy.haslo=\''.sha1($haslo).'\')) LIMIT 1'); else { include('includes/home.php'); } ?>
home.php
<html> <head> <title>Strona główna</title> <meta name="AUTHOR" content="A"> <meta http-equiv="Expires" content="0" /> <meta http-equiv="Cache-Control" content="no-store, no-cache, must-revalidate" /> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <style type="text/css"> <!-- #centrowanie {width:80%; min-width:1000px; max-width:3000px; margin: 0 auto;} #lewydiv {width:20%; min-width:200px; max-width:600px;} #glownydiv {width:80%; min-width:800px; max-width:2400px;} --> </style> </head> <body> { echo '<center>Witaj '.$rekord['login'].'!</center><br><br> Proszę skorzystać z menu po lewej strony, aby skorzystać z funkcjonalności tej strony.'; } else{echo '<center>Error 500001</center><br><center>Proszę skomunikować z aministratorem strony</center>';} ?> </body> </html>
funkcje.php
<?php //FUNKCJE //FUNKCJE WYKORZYSTYWANE W logowaniedosystemu.php function blad($a) { $tablica[]=$a; include('logowanie.php'); } ?>