Pomoc - Szukaj - U¿ytkownicy - Kalendarz
Pe³na wersja: [php/mysql]logowanie -> problem z sesja i headers;/
Forum PHP.pl > Forum > Przedszkole
proximo
Moglby mi ktos powiedziec co jest zle ?

  1. <?
  2. require('../common.php');
  3.  
  4. if (isset($_POST['submit'])){
  5.  
  6. if (empty($_POST['name'])){
  7. $messagen = '<font>Brak nazwy użytkownia</font><Br />';
  8. }else{
  9. $name = $_POST['name'];
  10. }
  11.  
  12. if (empty($_POST['pass'])){
  13. $messagep = '<font>Brak hasła</font><br />';
  14. }else{
  15. $pass = $_POST['pass'];
  16. }
  17.  
  18. if($name && $pass){
  19.  
  20. $sql= "SELECT * FROM tbl_user WHERE user_name='$name' AND user_pass=md5('$pass')";
  21. $result = $db->query($sql);
  22. $ile = $result;
  23. $ile_j = $ile->num_rows;
  24. $row = $result->fetch_array(MYSQL_ASSOC);
  25.  
  26. if($result){
  27.  
  28. $sql_acces = "SELECT * FROM tbl_range WHERE range_id='{$row['user_acces']}'";
  29. $result_acces = $db->query($sql_acces);
  30. $row_acces = $result_acces->fetch_array(MYSQL_ASSOC);
  31.  
  32. $sql_up = "UPDATE tbl_user SET user_last_login=NOW() WHERE user_id='{$row['user_id']}'";
  33. $result_up = $db->query($sql_up);
  34.  
  35. session_name('PHPSID');
  36.  
  37. $_SESSION['user'] = $row;
  38. $_SESSION['access'] = $row_acces;
  39.  
  40. header ("Location: admin.php");
  41. }else{
  42. header ("Location: error.php");
  43. }
  44.  
  45. }
  46.  
  47. }
  48.  
  49. echo '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
  50. <html>
  51. <head>
  52. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  53. <title>Strona klasy 2c</title>
  54. <link rel="stylesheet" href="styles.css" type="text/css" media="all">
  55. <script LANGUAGE="JavaScript" SRC="script.js"></script>
  56. </head>
  57. <body bgcolor="#ffffff" text="#000000">
  58. <table align="center" width="400" cellspacing="0" cellpadding="0"><tr><td><br><br><br><br><br><br>';
  59.  
  60. table_open('Logowanie');
  61.  
  62. echo '<form method="post" action="index.php">
  63. <table align="center" border="0">
  64. <tr>
  65. <td align="right">Login:</td>
  66. <td><input type="text" name="name" size="30"></td>
  67. </tr>
  68. <tr>
  69. <td align="right">Hasło:</td>
  70. <td><input type="password" name="pass" size="30"></td>
  71. </tr>
  72. <tr>
  73. <td align="right"> </td>
  74. <td>
  75. <p align="center"><input style="font-weight: bold;" type="submit" name="submit" value="loguj">
  76. </td></tr>
  77. </table>
  78. </form>';
  79.  
  80. table_end();
  81.  
  82.  
  83. echo '</td></tr></table>';
  84.  
  85.  
  86. ?>


O to błedy

Kod
Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at C:\Programy\WebServ\httpd-users\cms_proximo\admin\index.php:1) in C:\Programy\WebServ\httpd-users\cms_proximo\admin\index.php on line 36

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at C:\Programy\WebServ\httpd-users\cms_proximo\admin\index.php:1) in C:\Programy\WebServ\httpd-users\cms_proximo\admin\index.php on line 36

Warning: Cannot modify header information - headers already sent by (output started at C:\Programy\WebServ\httpd-users\cms_proximo\admin\index.php:1) in C:\Programy\WebServ\httpd-users\cms_proximo\admin\index.php on line 41

Podobne bledy mam w innym pliku: admin.php -> z sesjami :/
zastosowalem ob_start i ob_end_flush ale dalej bledy sa ;/
strife
PHPedia::Cannot add header information - headers already sent

Przeczytaj dokładnie i uważnie. Wygląda na to, że przed Twoim kodem jest jakaś spacja. Jeśli jesteś pewien, że przed <?php napewno nic nie ma spróbuj zapisać plik innym edytorem, kasując wszystko co jest przed <?php ( więcej w linku który podałem ).

Poza tym, użyłeś złego bbCODE, do kodu php, na tym forum jest odpowiedni tag => [php] Prosiłbym, abyś to poprawił.

Pozdrawiam!
proximo
ok to tylko pomoglo na kompie (po ustawieniu php.ini).... natomiast na hostingu nie zabardzo... pomecze sie jeszcze moze wyjdzie

@EDIT:

Ok poradziłem sobie... A wszystko przez pliki bo byly ukryte znaki ktorych nie widac w notatniku ++ i frontpage..
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.