Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: session_start();
Forum PHP.pl > Forum > Przedszkole
mitp
Witam. Mam pewien problem, którego nie moge za bardzo rozwiązać.

+mam baze
+skrypt odwolujacy sie do bazy
+pare innych drobiazgów
-problem z sesjami

pliki: logowanie.php
-----------------------
  1. <?php
  2. if (($login=='') AND ($haslo=='')){
  3. include("blad.php");
  4. }
  5. include("polacz.php");
  6. $zapytanie=mysql_query("SELECT * FROM X WHERE Y='$login' and haslo='$haslo'");
  7. if (mysql_num_rows($zapytanie)>0)
  8. {
  9.         session_start();
  10.         session_register("login");
  11. $wiersz=mysql_fetch_array($zapytanie);
  12. $status=$wiersz['status'];
  13.         header("Location: menu.php?status=$status");
  14.   mysql_free_result($zapytanie);
  15.         mysql_close;
  16. }
  17. else
  18. {
  19. echo('Brak połączenia z bazą danych!<br><a href="index.php">Sprobuj jeszcze raz</a>');
  20. }  
  21. ?>



plik: błąd php:
----------------
  1. <?
  2. print "Nie jesteś zalogowany jako administrator<br>";
  3. print "<a href=index.php>Kliknij tu, aby się zalogować</a>";
  4. ?>



plik: polacz.php
------------------------
  1. <?
  2. function polacz()
  3. {
  4. $sql=mysql_connect("localhost","login","haslo");
  5. mysql_select_db ("cos");
  6. }
  7. polacz();
  8. ?>


no i plik menu.php:
----------------------
  1. <?
  2. if (!isset($login)){
  3. include("blad.php");
  4. }
  5. else
  6. {
  7. $data_dzis=date("Y-m-d");
  8. print "<table align=center border=0 width=100%>";
  9.   print "<tr><td><p align=light>".$data_dzis."</p></td></tr>";
  10.   print "<tr><td><p align=right><b>Zalogowany jako ".$login." status ".$status."</b></p></td></tr>";
  11.   print "<tr><td><p align=right><a href=wyloguj.php>Wyloguj się</a></p></td></tr>";
  12. print "</table>";
  13. menu($status);
  14. }
  15.  
  16. itd
  17.  
  18. ?>



no i w czym problem ?


Kiedy wszystko zostawie w takiej formie jak jest to nie ma problemu, dzila jak należy slicznie i zajefajnie.........ale

jak chcę wzbogacić conieco stronę grafika to co się dzieje :

oblozenie stronki nieco grafika:
plik. logowanie.php
----------------------

  1. tu naglowki - pominiete
  2.  
  3. <body topmargin="0" leftmargin="0" rightmargin="0" bottommargin="0">
  4.  
  5.  
  6. <table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%" id="AutoNumber1">
  7. <tr>
  8. <td width="100%">
  9. <div align="center">
  10. <center>
  11. <table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="590" id="AutoNumber2">
  12. <tr>
  13. <td width="100%">
  14. <p align="right">
  15. <img border="0" src="images/6_1.gif" width="1" height="6"></td>
  16. </tr>
  17. <tr>
  18. <td width="100%">
  19. <div align="center">
  20. <center>
  21. <table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="420" id="AutoNumber3">
  22. <tr>
  23. <td width="100%">
  24. <img border="0" src="images/naglowek.gif" width="420" height="54"></td>
  25. </tr>
  26. <tr>
  27. <td width="100%">
  28. <p align="right">
  29. <img border="0" src="images/6_1.gif" width="1" height="32"></td>
  30. </tr>
  31. <tr>
  32. <td width="100%" class="normal">
  33. <div align="center">
  34. <center>
  35. <table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="205" id="AutoNumber6">
  36. <tr>
  37. <td width="100%" class="normal">
  38. <p align="justify"><b>A</b>by skorzystać z panelu administratora musisz 
  39. się zalogować !</td>
  40. </tr>
  41. </table>
  42. </center>
  43. </div>
  44. </td>
  45. </tr>
  46. <tr>
  47. <td width="100%">
  48. <p align="right">
  49. <img border="0" src="images/6_1.gif" width="1" height="18"></td>
  50. </tr>
  51. <tr>
  52. <td width="100%">
  53. <div align="center">
  54. <center>
  55. <table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="205" id="AutoNumber4">
  56. <tr>
  57. <td width="100%">
  58. <img border="0" src="images/n_.gif" width="205" height="8"></td>
  59. </tr>
  60. <tr>
  61. <td width="100%" background="images/t_.gif" valign="top">
  62. <table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%" id="AutoNumber7">
  63. <tr>
  64. <td width="100%" class="normal">
  65. <p align="right">
  66. <img border="0" src="images/6_1.gif" width="1" height="6"></td>
  67. </tr>
  68. <tr>
  69. <td width="100%" class="normal">
  70. <div align="center">
  71. <center>
  72. <table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="90%" id="AutoNumber8">
  73. <tr>
  74. <td width="100%" class="normal">
  75.  
  76.  
  77. <!---logowania-formularz---->
  78.  
  79.  
  80. <?php
  81.  
  82. if (($login=='') AND ($haslo=='')){
  83. include("blad.php");
  84. }
  85. include("polacz.php");
  86. $zapytanie=mysql_query("SELECT * FROM egzaminatorzy WHERE kod_egz='$login' and haslo='$haslo'");
  87. if (mysql_num_rows($zapytanie)>0)
  88. {
  89.  
  90.  session_register("login");
  91. $wiersz=mysql_fetch_array($zapytanie);
  92. $status=$wiersz['status'];
  93.  header("Location: menu.php?status=$status");
  94.  mysql_free_result($zapytanie);
  95. }
  96. else
  97. {
  98. echo('Błędny login i/lub hasło !<br><br><a href="index.php">
  99. <font color=#336699>wprowadź ponownie</font></a>');
  100. }
  101.  
  102. ?>
  103.  
  104.  
  105. <!---/logowania-formularz--->
  106.  
  107.  
  108. </td>
  109. </tr>
  110. </table>
  111. </center>
  112. </div>
  113. </td>
  114. </tr>
  115. <tr>
  116. <td width="100%" class="normal">
  117. <p align="right">
  118. <img border="0" src="images/6_1.gif" width="1" height="3"></td>
  119. </tr>
  120. <tr>
  121. <td width="100%" class="normal">
  122. <p align="right">
  123. <img border="0" src="images/6_1.gif" width="1" height="5"></td>
  124. </tr>
  125. </table>
  126. </td>
  127. </tr>
  128. <tr>
  129. <td width="100%">
  130. <img border="0" src="images/s_.gif" width="205" height="9"></td>
  131. </tr>
  132. </table>
  133. </center>
  134. </div>
  135. </td>
  136. </tr>
  137. </table>
  138. </center>
  139. </div>
  140. </td>
  141. </tr>
  142. <tr>
  143. <td width="100%">&nbsp;</td>
  144. </tr>
  145. <tr>
  146. <td width="100%">&nbsp;</td>
  147. </tr>
  148. <tr>
  149. <td width="100%">&nbsp;</td>
  150. </tr>
  151. </table>
  152. </center>
  153. </div>
  154. </td>
  155. </tr>
  156. </table>
  157.  
  158.  
  159. </body>
  160. </html>


to po takiej zmianie wyskakuje mi od razu przy probie polaczenia:

Kod
Warning: session_start(): Cannot send session cookie - headers already sent by (output started at c:\usr\krasnal\www\test\logowanie.php:10) in c:\usr\krasnal\www\test\logowanie.php on line 98

Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at c:\usr\krasnal\www\test\logowanie.php:10) in c:\usr\krasnal\www\test\logowanie.php on line 98

Warning: Cannot modify header information - headers already sent by (output started at c:\usr\krasnal\www\test\logowanie.php:10) in c:\usr\krasnal\www\test\logowanie.php on line 102


i tu mogę rozlozyc rece i wolac o pomoc rolleyes.gif


poprawiam
---
nospor
nospor
to jest problem php a nie mysql. przenosze wiec na wlasciwe forum

poczytahj se to : http://php.pl/artykuly/dla_poczatkujacych/...ch_programistow
a znajdziesz rozwiazanie problemu

pozatym problem codziennie przewala sie na forum. uzywajcie wyszukiwarki !
np. dzisiaj : http://forum.php.pl/index.php?showtopic=37410 ostatnie posty

ps: i uzywaj odpowiedniego bbcode!
djmassive
Ustaw session_start(); na samym początku pliku, bynajmniej mnie to pomogło exclamation.gif
To jest wersja lo-fi głównej zawartości. Aby zobaczyć pełną wersję z większą zawartością, obrazkami i formatowaniem proszę kliknij tutaj.
Invision Power Board © 2001-2025 Invision Power Services, Inc.