index.php
<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-2" /> <title>Logowanie</title> </head> <body> <h2 align="center"> <?php else ?> </h2> <form name = "formularz1" action = "http://localhost/login.php" method = "POST" > <table border="0" align="center"><tr> <td>Użytkownik:</td > <td> <input type="text" name="user"> </td> </tr><tr> <td>Hasło:</td> <td> <input type="password" name="haslo"> </td> </tr><tr> <td colspan="2" align="center"> <input type="submit" value="Wejdź"> </td> </tr> </table> </form> </body> </html>
login.php
<?PHP function checkPass($user, $pass) { if($userNameLength < 3 || $userNameLength > 20 || $userPassLength < 6 || $userNameLength > 40){ return 2; } //echo('Wystąpił błąd podczas próby połączenia z serwerem MySQL...'); return 1; } //echo('Wystapł błąd podczas wyboru bazy danych: snetcrm ...'); return 1; } $query = "SELECT COUNT(*) FROM Users WHERE Nazwa='$user' "; $query .="AND Haslo='$pass'"; //echo('Wystąpł błąd: nieaprawidłowe zapytanie...') return 1; } //echo('Wystąpł błąd: nieprawidłowe wyniki zapytania...') return 1; } else{ if($row[0] <> 1){ return 2; } else{ return 0; } } } } $_SESSION['komunikat'] = "WprowadĽ nazwę i hasło użytkonika:"; include('index.php'); } else{ $val = chceckPass($_POST["user"], $_POST["haslo"]); if($val == 0){ $_SESSION['zalogowany'] = $_POST["user"]; } else if($val == 1){ $_SESSION['kominikat'] = "Błąd sewera. Zalogowanie nie było możliwe."; include('index.php'); } else if($val == 2){ $_SESSION['komunikat'] = "Nieprawidłowa nazwa lub hasło użytkownika."; include('index.php'); } else{ $_SESSION['komunikat'] = "błąd serwera. Zalogowanie nie było możliwe"; include('index.php'); } } ?>
main.php
<?php $_SESSION['komunikat'] = "Nie jesteś zalogowany!"; include('index.php'); } ?> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-2" /> <title>Snet Crm</title> </head> <body> </br> Pamiętaj o wylogowaniu przed opuszczeniem strony ! <br> <br> <a href="logout.php">Wylogowywanie</a> </body> </html>
POwiedzcie gdzie zrobiłem błąd bo ja już walczę z tym zbyt długo. Wiem że kod jest pomieszany ale jestem początkujący więc wszelkie rady związku z poprawą skryptu są jak najbardziej mile widziane.
Heh

błąd serwera. Zalogowanie nie było możliwe
hmm ciekawe co teraz nie działa ....