Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> [PHP]Problem - nie zapisuje sesji.
kleszcz12
post 22.09.2008, 10:20:41
Post #1





Grupa: Zarejestrowani
Postów: 102
Pomógł: 0
Dołączył: 16.03.2008

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


Witam, co tutaj jest nie tak?

  1. <?php
  2. ?>
  3. <form name="login" action="recenzje_punkty.php" method="post"> 
  4. <input type="text" name="login">
  5. <input type="submit" value="wyslij">
  6. </form>
  7.  
  8.  
  9. <?
  10. $_POST['login'] = $_SESSION['login'];
  11.  
  12. ?>


Chodzi o to żeby po wpisaniu tekstu w formularzu, był on zapisywany do sesji.Jednak nie działa.
Go to the top of the page
+Quote Post
wookieb
post 22.09.2008, 10:22:17
Post #2





Grupa: Moderatorzy
Postów: 8 989
Pomógł: 1550
Dołączył: 8.08.2008
Skąd: Słupsk/Gdańsk




Kod
$_POST['login'] = $_SESSION['login'];

No to zobacz o przypisywaniu wartości do zmiennych i pomyśl dlaczego ta linijką jest błędna...
Kod
$_SESSION['login']=$_POST['login'];


Ten post edytował wookieb 22.09.2008, 10:22:25


--------------------
Go to the top of the page
+Quote Post
kleszcz12
post 22.09.2008, 10:26:35
Post #3





Grupa: Zarejestrowani
Postów: 102
Pomógł: 0
Dołączył: 16.03.2008

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


tak tez nie działa...

  1. <?php
  2. ?>
  3. <form name="login" action="recenzje_punkty.php" method="post"> 
  4. <input type="text" name="login">
  5. <input type="submit" value="wyslij">
  6. </form>
  7.  
  8.  
  9. <?
  10. $_SESSION['login']=$_POST['login'];
  11.  
  12. ?>
Go to the top of the page
+Quote Post
wookieb
post 22.09.2008, 10:29:45
Post #4





Grupa: Moderatorzy
Postów: 8 989
Pomógł: 1550
Dołączył: 8.08.2008
Skąd: Słupsk/Gdańsk




Ale co ty chcesz dokładnie zrobić? No jak nie działa jak musi działać jeżeli ktoś wysłał formularz.


--------------------
Go to the top of the page
+Quote Post
kleszcz12
post 22.09.2008, 10:31:37
Post #5





Grupa: Zarejestrowani
Postów: 102
Pomógł: 0
Dołączył: 16.03.2008

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


Cytat(wookieb @ 22.09.2008, 11:29:45 ) *
Ale co ty chcesz dokładnie zrobić? No jak nie działa jak musi działać jeżeli ktoś wysłał formularz.



Wyświetla tylko na podstronie z formularzem, ale jak przejde na inną podstrone z 

  1. <?php
  2. echo $_SESSION['login']
  3. ?>




to nie wyświetla...

Ten post edytował kleszcz12 22.09.2008, 10:32:02
Go to the top of the page
+Quote Post
wookieb
post 22.09.2008, 10:32:22
Post #6





Grupa: Moderatorzy
Postów: 8 989
Pomógł: 1550
Dołączył: 8.08.2008
Skąd: Słupsk/Gdańsk




A czy na tej stronie "z" masz session_start(); na poczatku strony?


--------------------
Go to the top of the page
+Quote Post
kleszcz12
post 22.09.2008, 10:43:07
Post #7





Grupa: Zarejestrowani
Postów: 102
Pomógł: 0
Dołączył: 16.03.2008

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


tak...

A sorry...już działa..coś z plikiem było nie tak...

Kurcze...teraz z koleji mi całość nie działa...jak klikne "drugie" zapisz to tak jakby sesje się resetowały, i pojawia się 

Warning: fopen(../users/_punkty.php) [function.fopen]: failed to open stream: No such file or directory in /home/filmy/domains/public_html/admin/recenzje_punkty.php on line 49

Warning: filesize() [function.filesize]: stat failed for ../users/_punkty.php in /home/filmy/domainsl/public_html/admin/recenzje_punkty.php on line 52

Warning: fread(): supplied argument is not a valid stream resource in /home/filmy/domains//public_html/admin/recenzje_punkty.php on line 52

Warning: rewind(): supplied argument is not a valid stream resource in /home/filmy/domains//public_html/admin/recenzje_punkty.php on line 55

Warning: flock() expects parameter 1 to be resource, boolean given in /home/filmy/domains/public_html/admin/recenzje_punkty.php on line 58

Warning: fwrite(): supplied argument is not a valid stream resource in /home/filmy/domains//public_html/admin/recenzje_punkty.php on line 60

Warning: flock() expects parameter 1 to be resource, boolean given in /home/filmy/domains//public_html/admin/recenzje_punkty.php on line 62

Warning: fclose(): supplied argument is not a valid stream resource in /home/filmy/domains//public_html/admin/recenzje_punkty.php on line 64



  1. <?php
  2. ?>
  3. <form name="login" action="recenzje_punkty.php" method="post"> 
  4. <input type="text" name="login">
  5. <input type="submit" value="wyslij">
  6. </form>
  7.  
  8.  
  9.  
  10.  
  11. <?
  12. $_SESSION['login']=$_POST['login'];
  13. echo:";
  14. echo $_SESSION['login'];
  15. echo:";
  16. echo $_POST['login'];
  17. ?>
  18.  
  19. <?
  20. $pole1 = trim($_POST['pole1']);
  21. $pole2 = trim($_POST['pole2']);
  22.  
  23. if(empty($pole1) and empty($pole2)) {
  24.  
  25.  
  26. echo '<center><form action="recenzje_punkty.php" method="post">
  27. N:<br><input type="text" name="pole1" style="w: 400px;" /><br /><br>
  28. Tre:<br><textarea name="pole2" style="w: 400px; he: 100px;" /></textarea><br />
  29. <input type="submit" value="ZAPISZ DANE!" />
  30. </form>';
  31. }
  32. else {
  33.  
  34.  
  35. $dane = 
  36. "T:<b>".
  37. $pole1."</b><br>".
  38.  
  39. $pole2."<br>Dodane pr:<a href=../users/$login>".
  40. $login."</a><hr> \n"
  41.  
  42.  
  43.  
  44. ;
  45.  
  46. $file = '../users/'.$_SESSION['login'].'_punkty.php';
  47.  
  48. $fp=fopen(''.$file.'', "r+");
  49.  
  50.  
  51. $dane=$dane.fread($fp, filesize($file));
  52.  
  53.  
  54. rewind($fp);
  55.  
  56. flock($fp, 2);
  57.  
  58. fwrite($fp, $dane);
  59.  
  60. flock($fp, 3);
  61.  
  62. fclose($fp);
  63.  
  64. echo "Dane zostały zapisane!<br /> ";
  65.  
  66. } 
  67.  
  68. ?>


Ten post edytował kleszcz12 22.09.2008, 10:44:01
Go to the top of the page
+Quote Post
wookieb
post 22.09.2008, 10:47:11
Post #8





Grupa: Moderatorzy
Postów: 8 989
Pomógł: 1550
Dołączył: 8.08.2008
Skąd: Słupsk/Gdańsk




Bo wysłałes formularz bez pola login a przeciez wtedy pole seesji jest nadpisane przez
Kod
$_SESSION['login']=$_POST['login'];

Wiec jak jzu to daj
Kod
if(isset($_POST['login']) && !empty($_POST['login']))
{
$_SESSION['login']=$_POST['login'];
}


--------------------
Go to the top of the page
+Quote Post
kleszcz12
post 22.09.2008, 10:48:35
Post #9





Grupa: Zarejestrowani
Postów: 102
Pomógł: 0
Dołączył: 16.03.2008

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


Dzięki smile.gif
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 Wersja Lo-Fi Aktualny czas: 18.07.2025 - 10:09