Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> PHP, Firefox gubi elementy z tablicy sesji
xziomas
post 21.02.2014, 13:59:06
Post #1





Grupa: Zarejestrowani
Postów: 15
Pomógł: 0
Dołączył: 24.07.2013

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


Hej,
sprawa dosc dziwna bo wczesniej nie spotkalem sie z czyms takim, a mianowicie w firefoxie (tylko w nim) elementy sesji ktore podaje na jednej z podstron poprostu sie nie zapisuja, tworzony jest element tablicy ale nie przypisana zadna wartosc. ID sesji jest niezmienne i tak samo zmienne sesji ktore podaje przy logowaniu caly czas sa w tablicy... O co tu biega? smile.gif

Mial ktos podobny przypadek, bede wdzieczny za jakies drobne naprowadzenie smile.gif

Moge wkleic kod, ale w sumie to zwykle przypisanie zmiennej a dodatkowo tak samo mam w innym skrypcie i dziala biggrin.gif


  1. $_SESSION['temp_name'] = $zmienna;




Pozdrawiam,
Kuba
Go to the top of the page
+Quote Post
Turson
post 21.02.2014, 14:08:57
Post #2





Grupa: Zarejestrowani
Postów: 4 291
Pomógł: 829
Dołączył: 14.02.2009
Skąd: łódź

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


Pokaż więcej kodu
Go to the top of the page
+Quote Post
Pyton_000
post 21.02.2014, 14:16:38
Post #3





Grupa: Zarejestrowani
Postów: 8 068
Pomógł: 1414
Dołączył: 26.10.2005

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


Przechodzenie z adresu www na bez i vice versa, sprawdź czy nie masz przypadkiem 2x ustawione cookie z tym samym SESSION_ID,
Generalnie z tego co czytam gdzieś po różnych miejscach to ludzie mają podobne problemy
Go to the top of the page
+Quote Post
xziomas
post 25.02.2014, 08:49:28
Post #4





Grupa: Zarejestrowani
Postów: 15
Pomógł: 0
Dołączył: 24.07.2013

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


Plik1
  1. <?php
  2. include 'connect.php';
  3. $name = $_POST['temp_name'];
  4. $_SESSION['temp_name'] = $name;
  5.  
  6. $count = count(array_filter($_POST['question']));
  7.  
  8.  
  9. for ($x=0; $x<$count; $x++) {
  10.  
  11. $ww = $_POST['question'][$x];
  12. $q = "INSERT INTO templates (template_name, questions_ids) VALUES ('$name', '$ww')";
  13. mysqli_query($connect, $q);
  14.  
  15.  
  16. }
  17.  
  18. ?>
  19.  
  20. <!DOCTYPE html>
  21. <!--[if lt IE 7 ]> <html lang="en" class="no-js ie6 lt8"> <![endif]-->
  22. <!--[if IE 7 ]> <html lang="en" class="no-js ie7 lt8"> <![endif]-->
  23. <!--[if IE 8 ]> <html lang="en" class="no-js ie8 lt8"> <![endif]-->
  24. <!--[if IE 9 ]> <html lang="en" class="no-js ie9"> <![endif]-->
  25. <!--[if (gt IE 9)|!(IE)]><!--> <html lang="en" class="no-js"> <!--<![endif]-->
  26. <head>
  27. <meta charset="UTF-8" />
  28. <!-- <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> -->
  29. <title>Ambassadors Management</title>
  30. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  31. <meta name="description" content="Ambassadors Management Tool" />
  32. <meta name="keywords" content="ifs" />
  33. <meta name="author" content="xziomas" />
  34. <link rel="shortcut icon" href="">
  35. <link rel="stylesheet" type="text/css" href="css/demo.css" />
  36. <link rel="stylesheet" type="text/css" href="css/style.css" />
  37. <link rel="stylesheet" type="text/css" href="css/animate-custom.css" />
  38. </head>
  39. <body>
  40. <div class="container">
  41.  
  42.  
  43. <header>
  44. <h1><span>Template Creation Tool</span></h1>
  45.  
  46. </header>
  47. <section>
  48. <div id="container_demo" >
  49. <!-- hidden anchor to stop jump <a href="http://www.css3create.com/Astuce-Empecher-le-scroll-avec-l-utilisation-de-target#wrap4" target="_blank">http://www.css3create.com/Astuce-Empecher-...de-target#wrap4</a> -->
  50. <a class="hiddenanchor" id="toregister"></a>
  51. <a class="hiddenanchor" id="tologin"></a>
  52. <div id="wrapper" >
  53. <div id="login" class="animate form">
  54. <form method="post" action="cr_temp_save2.php" autocomplete="off">
  55.  
  56. <h1>Choose positions for questions</h1>
  57.  
  58. <p>
  59. <?php
  60. $q = "SELECT * FROM templates WHERE template_name ='$name'";
  61. //echo $q;
  62. $sql = mysqli_query($connect, $q);
  63. $questions_num = mysqli_num_rows($sql);
  64.  
  65. $i = 1;
  66. while ($r = mysqli_fetch_assoc($sql)) {
  67. $question_id[$i] = $r['questions_ids'];
  68. //echo $question_id[$i];
  69. $i++;
  70. }
  71.  
  72.  
  73. foreach ($question_id as $value) {
  74.  
  75. $temp_query = "SELECT * FROM questions WHERE questions_id = $value";
  76. $temp_sql = mysqli_query($connect, $temp_query);
  77. $result = mysqli_fetch_assoc($temp_sql);
  78. $temp_question = $result['question'];
  79. echo $temp_question." "."<select name='$value' value=''><option value='".$x."'>".$x."</option>";
  80. for ($x=1;$x<$count;$x++) {
  81. echo "<option value='".$x."'>".$x."</option>";
  82. }
  83. echo "</select>";
  84. }
  85.  
  86.  
  87.  
  88.  
  89. ?></p>
  90.  
  91. <p class="login button">
  92. <input type="submit" value="Save TEMPLATE" />
  93. </p>
  94.  
  95.  
  96.  
  97. </form>
  98.  
  99. </div>
  100.  
  101.  
  102.  
  103. </div>
  104. </div>
  105.  
  106. </section>
  107. </div>
  108. </body>
  109. </html>
  110.  
  111.  
  112.  
  113.  
  114.  
  115.  
  116.  
  117.  
  118.  
  119.  
  120.  
  121.  
  122. <?php/*
  123.  
  124.  
  125.   $url = 'template_list.php';
  126.   echo '<META HTTP-EQUIV=Refresh CONTENT="0; URL='.$url.'">';
  127.  
  128.  */
  129. ?>


plik2:
  1. <?php
  2. include 'connect.php';
  3. $name = $_SESSION['temp_name'];
  4.  
  5.  
  6.  
  7.  
  8.  
  9. foreach ($_POST as $key=>$value) {
  10.  
  11.  
  12. $query = "UPDATE templates SET position = $value WHERE questions_ids = $key AND template_name = '$name'";
  13.  
  14. mysqli_query($connect, $query);
  15.  
  16. }
  17.  
  18.  
  19. mysqli_close($connect);
  20. $url = 'template_list.php';
  21. echo '<META HTTP-EQUIV=Refresh CONTENT="0; URL='.$url.'">';
  22.  


Bump! smile.gif
Go to the top of the page
+Quote Post
Pyton_000
post 25.02.2014, 20:02:10
Post #5





Grupa: Zarejestrowani
Postów: 8 068
Pomógł: 1414
Dołączył: 26.10.2005

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


  1. $name = $_POST['temp_name'];
  2. $_SESSION['temp_name'] = $name;
Go to the top of the page
+Quote Post
xziomas
post 27.02.2014, 14:14:24
Post #6





Grupa: Zarejestrowani
Postów: 15
Pomógł: 0
Dołączył: 24.07.2013

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


Pyton, sorki ale nei do konca rozumiem....
Go to the top of the page
+Quote Post
untorched
post 28.02.2014, 13:25:13
Post #7





Grupa: Zarejestrowani
Postów: 318
Pomógł: 76
Dołączył: 27.12.2011
Skąd: Dąbrowa Górnicza

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


Tak jak kolega wyżej napisał:
  1. <?php
  2. include 'connect.php';
  3. $name = $_POST['temp_name'];
  4. $_SESSION['temp_name'] = $name;


Ten kod uruchamiany jest przy każdym uruchomieniu pliku pierwszego. Z kodu wynika, że za każdym razem(nawet jeśli skrypt nie był wykonany metodą POST) ustawiasz $_SESSION['temp_name'] na właśnie wartość z POST. Innymi słowy jak nie wykonujesz skryptu metodą POST czyścisz sobie zawartość $_SESSION['temp_name'].

Powyższy kod można uprościć do:
  1. $_SESSION['temp_name'] = $_POST['temp_name'];


Więc? Cóż więcej? Dostałeś wszystko na talerzu.
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: 16.06.2025 - 19:47