Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> [php] puste value, nie laduje mi sie identyfikator sesji
Balon
post
Post #1





Grupa: Zarejestrowani
Postów: 422
Pomógł: 0
Dołączył: 14.12.2005
Skąd: Wałbrzych

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


Index.php do ktorego includowany jest add.php:
  1. <?
  2. ob_start();//Tworzenie sesji i sprawdzanie czy user zalogowal sie
  3.  
  4. if(isset($HTTP_POST_VARS['user']) && isset($HTTP_POST_VARS['pass']))
  5. {
  6. // Skrypt sprawdzajacy prawdziwosc danych podczas logowania
  7. $user = $HTTP_POST_VARS['user'];
  8. $pass = $HTTP_POST_VARS['pass'];
  9.  
  10. mysql_connect ("localhost","soonhost_balon","moje haslo");
  11. mysql_select_db('soonhost_newscenter');
  12. $zapytanie = 'select * from admins '
  13.  ."where user='$user' "
  14.  ." and pass='$pass'";
  15. $wynik = mysql_query($zapytanie);
  16. if(mysql_num_rows($wynik) > 0)
  17. {
  18. // Jezeli dane sa prawdziwe nastepuje zarejestrowanie identyfikatora usera
  19. $HTTP_SESSION_VARS['prawid_uzyt'] = $user;
  20. }
  21. }
  22. ?>
  23.  
  24.  
  25.  
  26.  
  27. <html>
  28. <head>
  29.  
  30. <title>Portal Newsowy - v 1.0.</title>
  31. <link rel="stylesheet" href="style.css" type="text/css" />
  32. <META name="keywords" content="Skrypt, BalonNews, Balon, News">
  33. <META name="description" content="Skrypt, BalonNews, Balon, News">
  34. <META name="author" content="Krzysztof Jagiello">
  35.  
  36. </head>
  37.  
  38. <body>
  39. <table border="0" height="25" width="600" align="center" cellpadding="0" cellspacing="0">
  40. <tr><td width="100%" height="100%"></td></tr>
  41.  
  42. <table border="0" height="50" width="600" align="center" cellpadding="0" cellspacing="0">
  43. <tr><td width="100%" height="100%"></td></tr>
  44.  
  45.  
  46. </table>
  47.  
  48. <?
  49. // sprawdzanie istnienia sesji
  50. if(isset($HTTP_SESSION_VARS['prawid_uzyt']))
  51. {
  52.  
  53. // includowanie podstron
  54. if($co=="main") { include "inc/main.php"; }
  55. elseif($co=="add") { include "inc/add.php"; }
  56. elseif($co=="edit") { include "inc/edit.php"; }
  57. else { include "inc/main.php"; }
  58.  
  59. //dalsza czesc uwierzytelniania
  60. }
  61. else
  62. {
  63. if(isset($user))
  64. {
  65. // jezeli proba logowania nie powiodla sie
  66. echo '<table bgcolor=3e3e3e border=0 width=600 align=center cellpadding=0 cellspacin
    g=0>'
    ;
  67. echo '<tr><td bgcolor=505050 width=100% height=25 class=news valign="middle"><b>Panel Admina - NewsCenter</b></td></tr>';
  68. echo '<tr><td bgcolor=3e3e3e width=100% class=news>';
  69. echo '<center><br><b>Zalogowanie niemozliwe.</b></center><br />';
  70. echo '</table>';
  71. }
  72. else
  73. {
  74. // Albo nastapilo wylogowanie albo nie bylo wogole proby logowania sie
  75. echo '<table bgcolor=3e3e3e border=0 width=600 align=center cellpadding=0 cellspacin
    g=0>'
    ;
  76. echo '<tr><td bgcolor=505050 width=100% height=25 class=news valign="middle"><b>Panel Admina - NewsCenter</b></td></tr>';
  77. echo '<tr><td bgcolor=3e3e3e width=100% class=news>';
  78. echo '<center><br><b>User niezalogowany.</b></center><br />';
  79. echo '</table>';
  80. }
  81.  
  82. // tworzenie formularza logowania
  83.  
  84. echo '<table bgcolor=3e3e3e border=0 width=600 align=center cellpadding=0 cellspacin
    g=0>'
    ;
  85. echo '<tr><td bgcolor=505050 width=100% height=25 class=news valign="middle"><b>Panel Admina - NewsCenter</b></td></tr>';
  86. echo '<tr><td bgcolor=3e3e3e width=100% class=news>';
  87. echo '<form method="post" action="index.php">';
  88. echo '<table border="0" class="news" align="center">';
  89. echo '<tr><td>Login</td><td><input type="text" name="user" style="font-family:verdana, tahoma, sans-serif; font-size:11px; color:#000066; border: 1px solid #000066"></td></tr>';
  90. echo '<tr><td>Haslo</td><td><input type="text" name="pass" style="font-family:verdana, tahoma, sans-serif; font-size:11px; color:#000066; border: 1px solid #000066"></td></tr>';
  91. echo '<tr><td></td><td><input type="submit" value="Loguj" style="font-family:verdana, tahoma, sans-serif; font-size:11px; color:#000066; border: 1px solid #000066"></td></tr>';
  92. echo '</table></form>';
  93. echo '<table border="0" width="600" align="center" cellpadding="0" cellspacing="0">
  94. <tr>
  95. <td class="news">
  96. </td>
  97. </tr>
  98. </table>
  99. </table>
  100. </td></tr>
  101. </table><br>';
  102. }
  103. ?>
  104.  
  105.  
  106. </body>
  107.  
  108. </html><? ob_end_flush(); ?>


add.php
  1. <tr><td bgcolor=3e3e3e width=100% class=news>
  2.  
  3.  
  4.  
  5. <?
  6. $adm = $HTTP_SESSION_VARS['prawid_uzyt'];
  7. if (isset($HTTP_POST_VARS['title']) && isset($HTTP_POST_VARS['autor']) && isset($HTTP_POST_VARS['tresc'])) {
  8. $title=$HTTP_POST_VARS['title'];
  9. $autor=$HTTP_POST_VARS['autor'];
  10. $tresc=$HTTP_POST_VARS['tresc'];
  11.  
  12. if (!$title || !$autor || !$tresc)
  13. {
  14.  
  15. echo 'Wypelnij wszystkie pola!';
  16.  
  17. }
  18.  
  19. $title=addslashes($title);
  20. $autor=addslashes($autor);
  21. $tresc=addslashes($tresc);
  22.  
  23.  
  24. mysql_connect ("localhost","soonhost_balon","moje haslo");
  25. mysql_select_db('soonhost_newscenter');
  26.  
  27.  
  28.  
  29. $zapytanie = "INSERT INTO `newsy` ( `id` , `title` , `autor` , `tresc` )
  30. VALUES ('', '$title', '$autor', '$tresc');";
  31.  
  32.  
  33. $wynik = mysql_query($zapytanie);
  34. if ($wynik) {
  35.  echo "News zostal dodany"; 
  36. }
  37. }
  38. ?>
  39.  
  40. <? if(isset($HTTP_SESSION_VARS['prawid_uzyt']))
  41. {?>
  42.  
  43. <form action="index.php?co=add" method="post">
  44. <table border="0" align="center" class="news">
  45. <tr>
  46. <td>Tytul:</td>
  47. <td><input type="text" name="title" size="15" style="font-family:verdana, tahoma, sans-serif; font-size:11px; color:#000066; border: 1px solid #000066"></td>
  48. </tr>
  49. <tr>
  50. <td>Tresc:</td><td><TEXTAREA name="tresc" rows="8" cols="70" wrap="virtual" style="font-family:verdana, tahoma, sans-serif; font-size:11px; color:#000066; border: 1px solid #000066"></TEXTAREA><BR></td></tr>
  51. <tr>
  52. <td><input type="reset" value="Resetuj" style="font-family:verdana, tahoma, sans-serif; font-size:11px; color:#000066; border: 1px solid #000066"></td>
  53. <td><input type="submit" value="Dodaj" style="font-family:verdana, tahoma, sans-serif; font-size:11px; color:#000066; border: 1px solid #000066"><input name="autor" value="<? $HTTP_SESSION_VARS['prawid_uzyt'] ?>" type="hidden"></td>
  54. </tr>
  55. </table>
  56. </form>
  57. <? } ?>
  58. </td></tr>
  59.  
  60. </table><br>


I chce zeby do value
Kod
<input name="autor" value="<? $HTTP_SESSION_VARS['prawid_uzyt'] ?>" type="hidden">
zostal wrzucony identyfikator sesji ktorym jest nazwa usera... tylko ze nie dzieje sie tak jak bym chcial i value jest puste... prosze o pomoc...


--------------------
Postura wielka i morda wredna, jestem Balon, kozak z osiedla !
bzdury.pl - Królestwo rozrywki
Go to the top of the page
+Quote Post
ennics
post
Post #2





Grupa: Zarejestrowani
Postów: 312
Pomógł: 0
Dołączył: 29.12.2004

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


  1. <input name="autor" value="<? print $HTTP_SESSION_VARS['prawid_uzyt']; ?>" type="hidden">

zrezygnuj z $HTTP_SESSION_VARS i $HTTP_POST_VARS
na rzecz $_SESSION i $_POST
i włącz obsługę błedów....

Ten post edytował ennics 18.12.2005, 18:41:30


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





Grupa: Moderatorzy
Postów: 1 566
Pomógł: 37
Dołączył: 14.05.2003
Skąd: Kraków




  1. <?php
  2. var_export($HTTP_SESSION_VARS);
  3. ?>

Pokaż co wypluwa.

  1. <input name="autor" value="<?= $HTTP_SESSION_VARS['prawid_uzyt']; ?>" type="hidden">


Ten post edytował Ociu 18.12.2005, 18:47:10
Go to the top of the page
+Quote Post
Balon
post
Post #4





Grupa: Zarejestrowani
Postów: 422
Pomógł: 0
Dołączył: 14.12.2005
Skąd: Wałbrzych

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


juz mi odpowiedzieli na f.wh.pl tak samo jak ociu z tym
  1. <?= $HTTP_SESSION_VARS['prawid_uzyt']; ?>


--------------------
Postura wielka i morda wredna, jestem Balon, kozak z osiedla !
bzdury.pl - Królestwo rozrywki
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: 19.08.2025 - 04:23