![]() |
![]() ![]() |
![]() |
![]()
Post
#1
|
|
Grupa: Zarejestrowani Postów: 17 Pomógł: 0 Dołączył: 30.12.2007 Ostrzeżenie: (0%) ![]() ![]() |
witam ,
mam problem z logowaniem, chcialbym zrobic logowanie na wszystkie podstrony moj plik config.php tak wyglada: <? $dbhost = 'localhost'; $dbuser = 'root'; $dbpass = 'krasnal'; $dbname = 'szkola'; $dbc = @mysql_connect($dbhost, $dbuser, $dbpass) or die ('Nie moge połaczyc sie z Mysql'); mysql_select_db ($dbname) or die ('Nie moge wybrać bazy'); ?> plik logowanie.html wyglada tak: <? ob_start(); session_start(); if($_SESSION['access'] != 'root'){ @header ("Location: index.html"); } echo 'dziala:)'; ob_end_flush(); ?> <? ob_start(); require_once('./config.php'); function usun($data){ GLOBAL $dbc; if (ini_get('magic_quotes_gpc')){ $data = stripslashes($data); } return mysql_real_escape_string($data, $dbc); } if (isset($_POST['submit'])){ if (empty($_POST['login'])){ $message .= '<font class="blad">Nie podałeś loginu</font><br />'; $l = FALSE; }else{ $l = usun($_POST['login']); } if (empty($_POST['haslo'])){ $message .= '<font class="blad">Nie podałeś hasła</font><br />'; $h = FALSE; }else{ $h = usun($_POST['haslo']); } if ( $l && $h ){ $query = "SELECT username, access FROM user WHERE username='$l' AND haslo=password('$h')"; $result = mysql_query($query); $row = mysql_fetch_array ($result, MYSQL_ASSOC); if($row){ session_start(); $_SESSION['username'] = $row['username']; $_SESSION['access'] = $row['access']; $_GET['cmd'] = 'ok'; header ("Location: index.html?cmd={$_GET['cmd']}"); }else{ $message .= 'Błędne hasło lub login<br />'; } mysql_close(); }else{ $message .= 'Spróbuj jeszcze raz'; } } ob_end_flush(); ?> <form method="post" action="<? echo $_SERVER['PHP_SELF']; ?>"> <table align="center" border="0"> <tr> <td align="right" class="uni_01">Login:</td> <td><input type="text" name="login" size="30"></td> </tr> <tr> <td align="right" class="uni_01">hasło:</td> <td><input type="text" name="haslo" size="30"></td> </tr> <tr> <td align="right" class="uni_01"> </td> <td> <p align="center"><input style="font-weight: bold;" type="submit" name="submit" value="loguj"> </td></tr> </table> </form> <div align="center"> <? if(isset($message)){ echo $message; } ?> </div> gdzie jest blad? bylbym bardzo wdzieczny za pomoc |
|
|
![]()
Post
#2
|
|
Grupa: Zarejestrowani Postów: 16 Pomógł: 0 Dołączył: 21.08.2007 Ostrzeżenie: (0%) ![]() ![]() |
a co nie działa ? jakis blad wylatuje czy jak ?
zreszta jak się kod php wstawia w 'logowanie.html' to nie dziwne ze ie działa, no chyba że sobie taka pache przestawiłeś ![]() |
|
|
![]() ![]() |
![]() |
Wersja Lo-Fi | Aktualny czas: 14.08.2025 - 01:05 |