Skocz do zawartości

r   e   k   l   a   m   a

Zdjęcie

Skrypt PHP Logowanie


  • Zaloguj się, aby dodać odpowiedź
1 odpowiedzi w tym temacie

#1 barsa121

barsa121
  • Użytkownicy
  • 55 postów

Napisano 02.01.2010 - 19:47

Potrzebuje skrypt logowania i baze danych. A i żeby jak ktos się nie zaloguje nie pokaże mu się zawartoć strony...

#2 master of disaster

master of disaster
  • Użytkownicy
  • 715 postów

Napisano 02.01.2010 - 19:56

Chyba najprostszy skrypt logowania:
<span class="syntaxdefault"></span><span class="syntaxkeyword"><?</span><span class="syntaxdefault">phpsession_start</span><span class="syntaxkeyword">();</span><span class="syntaxdefault">if </span><span class="syntaxkeyword">(isset(</span><span class="syntaxdefault">$_SESSION</span><span class="syntaxkeyword">[</span><span class="syntaxstring">'zalogowany'</span><span class="syntaxkeyword">])&&(</span><span class="syntaxdefault">$_SESSION</span><span class="syntaxkeyword">[</span><span class="syntaxstring">'zalogowany'</span><span class="syntaxkeyword">]===</span><span class="syntaxdefault">1</span><span class="syntaxkeyword">))</span><span class="syntaxdefault"> </span><span class="syntaxkeyword">{</span><span class="syntaxdefault">    header</span><span class="syntaxkeyword">(</span><span class="syntaxstring">"Location: admin.php"</span><span class="syntaxkeyword">);</span><span class="syntaxdefault">     </span><span class="syntaxkeyword">}</span><span class="syntaxdefault">if </span><span class="syntaxkeyword">(isset(</span><span class="syntaxdefault">$_POST</span><span class="syntaxkeyword">[</span><span class="syntaxstring">'haslo'</span><span class="syntaxkeyword">])){</span><span class="syntaxdefault">    if </span><span class="syntaxkeyword">(</span><span class="syntaxdefault">$_POST</span><span class="syntaxkeyword">[</span><span class="syntaxstring">'haslo'</span><span class="syntaxkeyword">]</span><span class="syntaxdefault"> </span><span class="syntaxkeyword">===</span><span class="syntaxdefault"> </span><span class="syntaxstring">"haslo"</span><span class="syntaxkeyword">)</span><span class="syntaxdefault">    </span><span class="syntaxkeyword">{</span><span class="syntaxdefault">        $_SESSION</span><span class="syntaxkeyword">[</span><span class="syntaxstring">'zalogowany'</span><span class="syntaxkeyword">]</span><span class="syntaxdefault"> </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> 1</span><span class="syntaxkeyword">;</span><span class="syntaxdefault">        header</span><span class="syntaxkeyword">(</span><span class="syntaxstring">"Location: dlaZalogowanych.php"</span><span class="syntaxkeyword">);</span><span class="syntaxdefault">                 </span><span class="syntaxkeyword">}</span><span class="syntaxdefault">    else     </span><span class="syntaxkeyword">{</span><span class="syntaxdefault">        header</span><span class="syntaxkeyword">(</span><span class="syntaxstring">"Location: dlaNieZalogowanych.php"</span><span class="syntaxkeyword">);</span><span class="syntaxdefault">    </span><span class="syntaxkeyword">}}</span><span class="syntaxdefault"> </span>

Poza tym Google nie boli :-|