Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> Logowanie na Cookies, problem ze skryptem logowania
Reiven
post
Post #1





Grupa: Zarejestrowani
Postów: 100
Pomógł: 1
Dołączył: 17.03.2006

Ostrzeżenie: (0%)
-----


Witam, po wielu mordęgach udało mi sie sklepać w skrypt logowania, lecz wyskakuje mi błąd:

Kod
Warning: Cannot modify header information - headers already sent by (output started at C:\Program Files\WebServ\httpd\news\zaloguj.php:2) in C:\Program Files\WebServ\httpd\news\zaloguj.php on line 33

i nie wiem co złego zrobiłem.
oto kod:
Kod
<?php
include ('config.php');
$db = mysql_connect ("$host", "$login", "$pass");
mysql_select_db ($baza);

$login = $_POST['user'];
$haslo = $_POST['haslo'];

$query = "SELECT * FROM admin WHERE user='$user'; ";
$result = mysql_query ($query);
$ile_user = mysql_num_rows($result);

if ($ile_user > 0)
{
$query2 = "SELECT * FROM admin WHERE user='$user' AND haslo='$haslo';";
$result2 = mysql_query ($query2);
$ile_user2 = mysql_num_rows($result2);

if ($ile_user2 > 0)
{
setcookie ("user2_c", $user,time()+3600);
setcookie ("haslo2_c", $haslo,time()+3600);
header("Location: admin.php?s=zobacz");
}
else
{
header("Location: index.php");        
}
}
else
{
header("Location: index.php");
}

mysql_close ($db);
?>
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
Reiven
post
Post #2





Grupa: Zarejestrowani
Postów: 100
Pomógł: 1
Dołączył: 17.03.2006

Ostrzeżenie: (0%)
-----


hmmm.... teraz to wogole nawet jak zalogowany jestem to nie działa, jużci pokazuje jak to u mnie wygląda:

zaloguj.php
  1. <?php
  2. include ('config.php');
  3. $db = mysql_connect ("$host", "$login", "$pass");
  4. mysql_select_db ($baza);
  5.  
  6. $login = $_POST['user'];
  7. $haslo = $_POST['haslo'];
  8.  
  9. $query = "SELECT * FROM admin WHERE user='$user'; ";
  10. $result = mysql_query ($query);
  11. $ile_user = mysql_num_rows($result);
  12.  
  13. if ($ile_user > 0)
  14. {
  15. $query2 = "SELECT * FROM admin WHERE user='$user' AND haslo='$haslo';";
  16. $result2 = mysql_query ($query2);
  17. $ile_user2 = mysql_num_rows($result2);
  18.  
  19. if ($ile_user2 > 0)
  20. {
  21. setcookie ("user2_c", $user,time()+3600); 
  22. setcookie ("haslo2_c", $haslo,time()+3600); 
  23. header("Location: index.php?f=home");
  24. }
  25. else
  26. {
  27. header("Location: index.php");
  28. }
  29. }
  30. else
  31. {
  32. header("Location: index.php");
  33. }
  34.  
  35. mysql_close ($db);
  36. ?>


nie będę pokazywał pliku index.php bo tam jest jedynie formularz do logowania.
PoZdro.

Ten post edytował Reiven 17.03.2006, 20:10:41
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 8.10.2025 - 02:18