Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> Problem z logowaniem
giciarz_1200`
post
Post #1





Grupa: Zarejestrowani
Postów: 33
Pomógł: 0
Dołączył: 3.08.2005

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


Mam takie coś:
  1. <?
  2.  
  3. echo '
  4. <table border="1" width="145" height="111" class="inside">
  5. <tr>
  6. <td height="15">
  7. <h6>Logowanie</h6></td>
  8. </tr>
  9. <tr>
  10. <td height="76">
  11. <p align="center">
  12. <FORM Action="'.$_SERVER['REQUEST_URI'].'" METHOD="POST">
  13. <input type="text" id="lg" name="log" size="20"><br>
  14. <input type="password" name="has" size="20"><br>
  15. <input type="submit" value="Loguj"></td>
  16. </form>
  17. </tr>
  18. </table>
  19. ';
  20.  
  21. $file = 'user.dat';
  22. $dane = file($file);
  23. $ile_wpisow = count($dane);
  24. $dane = array_reverse($dane);
  25.  
  26. if (isset($_COOKIE['loged']))
  27. {
  28. $loged = $_COOKIE['loged'];
  29. if ($loged == '1')
  30. {
  31. echo '
  32. <table border="1" width="145" height="111" class="inside">
  33. <tr>
  34. <td height="15">
  35. <h6>Konto użytkownika</h6>
  36. </td>
  37. </tr>
  38. <tr>
  39. <td height="76">
  40. <p align="left">
  41. Jesteś zalogowany/wana jako '.$_COOKIE['login'].'
  42. <form action="'.$_SERVER['REQUEST_URI'].'" method="post">
  43. <input type="hidden" name="loginout" value="1">
  44. <input type="submit" value="Wyloguj">
  45. </form>
  46. ';
  47. }
  48. } else {
  49. if (isset($_POST['loginout']))
  50. {
  51.  
  52. Header('Location:'.$_SERVER['REQUEST_URI']);
  53. setcookie('loged', '', 0);
  54. setcookie('login', '', 0);
  55. }
  56.  
  57. if (isset($_POST['log']) && isset($_POST['has']))
  58. {
  59.  
  60. if ($_POST['log'] <> '')
  61. {
  62. $log = $_POST['log'];
  63.  
  64.  
  65. if ($_POST['has'] <> '')
  66. {
  67. $has = $_POST['has'];
  68.  
  69. $loged=0;
  70.  
  71. for ($i = 0; $i <= $ile_wpisow - 1; $i++)
  72. {
  73. $info = explode('|', $dane[$i]);
  74. if ($log == $info[0])
  75. {
  76. if ($has == $info[1])
  77. {
  78. $loged=1;
  79. setcookie('loged', $loged, 0);
  80. setcookie('login', $log, 0);
  81. Header('Location:'.$_SERVER['REQUEST_URI']);
  82. break;
  83. } else { $error = 'pass_bad'; }
  84. } else { $error = 'log_bad'; }
  85. }
  86.  } else { $error = 'pass'; }
  87. } else { $error = 'log'; }
  88. }}
  89.  
  90. if (isset($_GET['error']))
  91. { $error = $_GET['error'];
  92. for ($i=0; $i<=$ile_wpisow-1; $i++) {$info = explode('|', $dane[$i]);
  93. $datas .= $info[0].'_'.$info[1].'<br>'; }}
  94.  
  95.  if (isset($error)) {
  96.  switch($error){
  97.  case 'log':
  98. echo '<font color="red"><b>Podaj login</font></b>';
  99. break;
  100.  case 'pass':
  101. echo '<font color="red"><b>Podaj hasło</font></b>';
  102. break;
  103.  case 'log_bad':
  104. echo '<font color="red"><b>Nieprawidłowe login</font></b>';
  105. break;
  106.  case 'pass_bad':
  107. echo '<font color="red"><b>Nieprawidłowe hasło</font></b>';
  108. break;
  109.  case 'loginw':
  110. echo '<font color="red"><b>'.$datas.'</font></b>';
  111. break;
  112.  }
  113.  }
  114. ?>


I wyskakują takie błędy:
Warning: Cannot modify header information - headers already sent by (output started at c:\program files\easyphp1-8\www\strona\index.php:15) in c:\program files\easyphp1-8\www\strona\login.php on line 79

Warning: Cannot modify header information - headers already sent by (output started at c:\program files\easyphp1-8\www\strona\index.php:15) in c:\program files\easyphp1-8\www\strona\login.php on line 80

Warning: Cannot modify header information - headers already sent by (output started at c:\program files\easyphp1-8\www\strona\index.php:15) in c:\program files\easyphp1-8\www\strona\login.php on line 81

Są to te linie:

setcookie('loged', $loged, 0);
setcookie('login', $log, 0);
Header('Location:'.$_SERVER['REQUEST_URI']);

Co mam zrobić żeby tych błędów nie było??
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi (1 - 5)
strife
post
Post #2





Grupa: Przyjaciele php.pl
Postów: 2 605
Pomógł: 96
Dołączył: 22.10.2004
Skąd: UK

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


LOL... znowu... masz na końcu..

http://php.pl/artykuly/dla_poczatkujacych/...ch_programistow


--------------------
Go to the top of the page
+Quote Post
giciarz_1200`
post
Post #3





Grupa: Zarejestrowani
Postów: 33
Pomógł: 0
Dołączył: 3.08.2005

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


Dodałem to i nadal jest
Go to the top of the page
+Quote Post
strife
post
Post #4





Grupa: Przyjaciele php.pl
Postów: 2 605
Pomógł: 96
Dołączył: 22.10.2004
Skąd: UK

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


Cytat(giciarz_1200` @ 2005-08-27 19:56:51)
Dodałem to i nadal jest

Rozumiem, że dodałeś to tak jak jest opisane w tym arcie, bez żadnych zbędnych spacji na początku?


--------------------
Go to the top of the page
+Quote Post
giciarz_1200`
post
Post #5





Grupa: Zarejestrowani
Postów: 33
Pomógł: 0
Dołączył: 3.08.2005

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


Tak
Go to the top of the page
+Quote Post
strife
post
Post #6





Grupa: Przyjaciele php.pl
Postów: 2 605
Pomógł: 96
Dołączył: 22.10.2004
Skąd: UK

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


Testowałem przed chwilą u siebie, jeśli mam tak http://dev.club.webhost.pl/source/ob_start.phps to wszystko działa bez problemu. Jeśli nie pomaga to już nie wiem czego to może być wina.. sad.gif

Z błędu wynika że masz coś przed wysłaniem nagłówka, musi tam coś być - sprawdź dokładniej.

Pozdrawiam!


--------------------
Go to the top of the page
+Quote Post

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

 



RSS Aktualny czas: 21.08.2025 - 14:41