Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP][MySQL] Problem z panelem logowania
sleedz
post
Post #1





Grupa: Zarejestrowani
Postów: 43
Pomógł: 0
Dołączył: 15.01.2008

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


  1. <?
  2.  
  3. include "config.php";
  4.  
  5.  
  6. $error='';
  7.  
  8. $wynik = mysql_query("SELECT * FROM users WHERE user='$user' ")
  9. or die('Błąd zapytania');
  10. $r = mysql_fetch_assoc($wynik);
  11. echo $r['user'];
  12. echo $r['pass'];
  13.  
  14. if (isset($_GET['logoff'])) {
  15. $_SESSION=array();
  16.  
  17. if (isset($_COOKIE[session_name()])) {
  18. setcookie(session_name(), '', time()-1000, '/');
  19. }
  20.  
  21. }
  22. elseif (isset($_SESSION['valid']) && $_SESSION['valid']) {
  23. header('Location: index.php');
  24. exit();
  25. }
  26.  
  27. elseif (isset($r['user']) || isset($r['pass'])) {
  28. $user = isset($r['user']) ? $r['user'] : '';
  29. $pass = isset($r['pass']) ? $r['pass'] : '';
  30. if ( ($user == $r['user']) && ($pass == $r['pass']) ) {
  31.  
  32. $_SESSION['valid'] = 1;
  33. $_SESSION['user'] = $r['user'];
  34. header('Location: index.php');
  35. exit();
  36. } else {
  37. $error = 'Niepoprawne dane użytkownika lub hasło.';
  38. }
  39. }
  40. ?>
  41.  
  42. <html>
  43. <head>
  44. <title>Logowanie</title>
  45. <style>
  46. form { border: 1px solid black; padding: 10px }
  47. #error { color: #FF0000; font-weight: bold; }
  48. </style>
  49. </head>
  50.  
  51. <body>
  52. <? 
  53. if ($error) { echo "<p id=\"error\">{$error}</p>\n"; }
  54. ?>
  55. <form action="<?= $_SERVER['PHP_SELF'] ?>" method="post">
  56. <p>Witamy na stronie (IMG:http://forum.php.pl/style_emoticons/default/tongue.gif) </p>
  57. <p>Login: <input type="test" name="user" value="<?= @$user ?>"> <br />
  58. Haslo: <input type="password" name="pass" value="<?= @$pass ?>"> </p>
  59. <p><input type="submit" value="Zaloguj" /></p>
  60. </form>
  61. </body>
  62. </html>


1. strona po zalogowaniu nie przełącza się na index.php
2. taki error: Warning: Cannot modify header information - headers already sent by (output started at E:\Programowanie\php\strona\login.php:12) in E:\Programowanie\php\strona\login.php on line 25

Nie wiem co z tym zrobić. Pomocy!
Go to the top of the page
+Quote Post

Posty w temacie


Closed TopicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 3.10.2025 - 19:00