Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: Przekazywanie zmiennych...
Forum PHP.pl > Forum > Przedszkole
djmassive
Witam,

Robie sobie właśnie stronke, i mam problem z przekazaniem zmiennej $language, którą przypisuje przy kliknięciu na np. Język Polski. Oto jak to wygląda:

index2.php
  1. <?php
  2.  $acms_root_path = "./";
  3.  $acms_last_path = "http://192.168.120.1/~www/";
  4.  
  5.  include($acms_root_path . "include/startinclude.inc");
  6.  
  7.  echo "<base target='_self'>";
  8.  
  9.  if ($mode=='polski')
  10.  {
  11.  $language="polski";
  12.  $_SESSION['lang'] = $language;
  13.  metastart("Witamy na oficjalnej stronie Internetowej - www.djmassive.com");
  14.  require($acms_root_path . 'templates/index_site.tpl');
  15.  exit;
  16.  }
  17.  
  18.  if ($mode=='english')
  19.  {
  20.  $language='english';
  21.  metastart("Welcome to official web site - www.djmassive.com");
  22.  require($acms_root_path . 'templates/index_site.tpl');
  23.  exit;
  24.  }
  25.  
  26. ?>


Strona index_site.tpl wyświetla się idealnie, i widzi zmienną $language.

index_site.tpl
  1. <?php
  2. include($acms_root_path . "language/" . $language . ".php");
  3.  
  4.  echo "<base target='I1'>
  5.  <head>
  6.  <script language='JavaScript' fptype='dynamicanimation'>
  7.  <!--
  8. function dynAnimation() {}
  9. function clickSwapImg() {}
  10.  //-->
  11.  </script>
  12.  <script language='JavaScript1.2' fptype='dynamicanimation' src='file:///C:/Program%20Files/Microsoft%20Office/Office10/fpclass/animate.js'></script>
  13.  </head>
  14.  
  15.  
  16. <div align='center'>
  17. <center>
  18. <table border='2' cellpadding='0' cellspacing='0' style='border-collapse: collapse' bordercolor='#111111' width='740' id='AutoNumber4' bgcolor='#FFFFFF' height='396'>
  19. <tr>
  20. <td width='100%' height='396'>
  21. "; scroller("left","700","15",$welcome_msg); echo "
  22. <table border='0' cellpadding='0' cellspacing='0' style='border-collapse: collapse' bordercolor='#111111' width='100%' id='AutoNumber5'>
  23. <tr>
  24. <td width='100%'>
  25. <img border='0' src='images/main_1.gif' width='740' height='33'></td>
  26. </tr>
  27. <tr>
  28. <td width='100%'>
  29. <a onmouseover='document['fpAnimswapImgFP1'].imgRolln=document['fpAnimswapImgFP1'].src;document['fpAnimswapImgFP1'].src=document['fpAnimswapImgFP1'].lowsrc;' onmouseout='document['fpAnimswapImgFP1'].src=document['fpAnimswapImgFP1'].imgRolln' title='Home' target='_top' href='index.php'>
  30. <img border='0' src='images/".$language."/home0.gif' id='fpAnimswapImgFP1' name='fpAnimswapImgFP1' dynamicanimation='fpAnimswapImgFP1' lowsrc='images/".$language."/home1.gif' width='98' height='33'></a><a target='I1' onmouseover='document['fpAnimswapImgFP2'].imgRolln=document['fpAnimswapImgFP2'].src;document['fpAnimswapImgFP2'].src=document['fpAnimswapImgFP2'].lowsrc;' onmouseout='document['fpAnimswapImgFP2'].src=document['fpAnimswapImgFP2'].imgRolln' title='".$about."' href='aboutme.php'><img border='0' src='images/".$language."/aboutme0.gif' id='fpAnimswapImgFP2' name='fpAnimswapImgFP2' dynamicanimation='fpAnimswapImgFP2' lowsrc='images/".$language."/aboutme1.gif' width='59' height='33'></a><a onmouseover='document['fpAnimswapImgFP3'].imgRolln=document['fpAnimswapImgFP3'].src;document['fpAnimswapImgFP3'].src=document['fpAnimswapImgFP3'].lowsrc;' onmouseout='document['fpAnimswapImgFP3'].src=document['fpAnimswapImgFP3'].imgRolln' title='".$production."' href='releases.php'><img border='0' src='images/".$language."/releases0.gif' id='fpAnimswapImgFP3' name='fpAnimswapImgFP3' dynamicanimation='fpAnimswapImgFP3' lowsrc='images/".$language."/releases1.gif' width='57' height='33'></a><a onmouseover='document['fpAnimswapImgFP4'].imgRolln=document['fpAnimswapImgFP4'].src;document['fpAnimswapImgFP4'].src=document['fpAnimswapImgFP4'].lowsrc;' onmouseout='document['fpAnimswapImgFP4'].src=document['fpAnimswapImgFP4'].imgRolln' title='".$ontour."' href='on-tour.php'><img border='0' src='images/".$language."/ontour0.gif' id='fpAnimswapImgFP4' name='fpAnimswapImgFP4' dynamicanimation='fpAnimswapImgFP4' lowsrc='images/".$language."/ontour1.gif' width='52' height='33'></a><a onmouseover='document['fpAnimswapImgFP5'].imgRolln=document['fpAnimswapImgFP5'].src;document['fpAnimswapImgFP5'].src=document['fpAnimswapImgFP5'].lowsrc;' onmouseout='document['fpAnimswapImgFP5'].src=document['fpAnimswapImgFP5'].imgRolln' title='".$download."' href='download.php'><img border='0' src='images/".$language."/download0.gif' id='fpAnimswapImgFP5' name='fpAnimswapImgFP5' dynamicanimation='fpAnimswapImgFP5' lowsrc='images/".$language."/download1.gif' width='57' height='33'></a><a onmouseover='document['fpAnimswapImgFP6'].imgRolln=document['fpAnimswapImgFP6'].src;document['fpAnimswapImgFP6'].src=document['fpAnimswapImgFP6'].lowsrc;' onmouseout='document['fpAnimswapImgFP6'].src=document['fpAnimswapImgFP6'].imgRolln' title='".$guest."' href='http://djmassive.com/modules/guestbook/index.php'><img border='0' src='images/".$language."/gb0.gif' id='fpAnimswapImgFP6' name='fpAnimswapImgFP6' dynamicanimation='fpAnimswapImgFP6' lowsrc='images/".$language."/gb1.gif' width='72' height='33'></a><a onmouseover='document['fpAnimswapImgFP7'].imgRolln=document['fpAnimswapImgFP7'].src;document['fpAnimswapImgFP7'].src=document['fpAnimswapImgFP7'].lowsrc;' onmouseout='document['fpAnimswapImgFP7'].src=document['fpAnimswapImgFP7'].imgRolln' title='".$forum."' href='http://community.djmassive.com' target='_blank'><img border='0' src='images/".$language."/forum0.gif' id='fpAnimswapImgFP7' name='fpAnimswapImgFP7' dynamicanimation='fpAnimswapImgFP7' lowsrc='images/".$language."/forum1.gif' width='42' height='33'></a><a onmouseover='document['fpAnimswapImgFP8'].imgRolln=document['fpAnimswapImgFP8'].src;document['fpAnimswapImgFP8'].src=document['fpAnimswapImgFP8'].lowsrc;' onmouseout='document['fpAnimswapImgFP8'].src=document['fpAnimswapImgFP8'].imgRolln' title='".$booking."' href='booking.php'><img border='0' src='images/".$language."/booking0.gif' id='fpAnimswapImgFP8' name='fpAnimswapImgFP8' dynamicanimation='fpAnimswapImgFP8' lowsrc='images/".$language."/booking1.gif' width='52' height='33'></a><a onmouseover='document['fpAnimswapImgFP9'].imgRolln=document['fpAnimswapImgFP9'].src;document['fpAnimswapImgFP9'].src=document['fpAnimswapImgFP9'].lowsrc;' onmouseout='document['fpAnimswapImgFP9'].src=document['fpAnimswapImgFP9'].imgRolln' title='".$links."' href='friends.php'><img border='0' src='images/".$language."/friends0.gif' id='fpAnimswapImgFP9' name='fpAnimswapImgFP9' dynamicanimation='fpAnimswapImgFP9' lowsrc='images/".$language."/friends1.gif' width='59' height='33'></a><a onmouseover='document['fpAnimswapImgFP10'].imgRolln=document['fpAnimswapImgFP10'].src;document['fpAnimswapImgFP10'].src=document['fpAnimswapImgFP10'].lowsrc;' onmouseout='document['fpAnimswapImgFP10'].src=document['fpAnimswapImgFP10'].imgRolln' title='".$contact."' href='contact.php'><img border='0' src='images/".$language."/contact0.gif' id='fpAnimswapImgFP10' name='fpAnimswapImgFP10' dynamicanimation='fpAnimswapImgFP10' lowsrc='images/".$language."/contact1.gif' width='154' height='33'></a><img border='0' src='images/".$language."/end.gif' width='38' height='33'></td>
  31. </tr>
  32. <tr>
  33. <td width='100%'>
  34. <img border='0' src='images/main_2.jpg' width='266' height='119'><img border='0' src='images/main_3.jpg' width='158' height='119'><img border='0' src='images/main_4.jpg' width='316' height='119'></td>
  35. </tr>
  36. <tr>
  37. <td width='100%'>
  38. <img border='0' src='images/main_5.gif' width='266' height='69'><img border='0' src='images/main_6.gif' width='474' height='69'></td>
  39. </tr>
  40. <tr>
  41. <td width='100%'>
  42. <table border='0' cellpadding='0' cellspacing='0' style='border-collapse: collapse' bordercolor='#111111' width='100%' id='AutoNumber6' height='1'>
  43. <tr>
  44. <td width='35%' height='1'>
  45. <table border='0' cellpadding='0' cellspacing='0' style='border-collapse: collapse' bordercolor='#111111' width='100%' id='AutoNumber7' bgcolor='#5F7B2A'>
  46. <tr>
  47. <td width='100%' bgcolor='#5F7B2A'>
  48. <object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000'
  49. codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,42,0'
  50. id='Movie1' width='240' height='164' align='absmiddle'>
  51. <param name='movie' value='images/tvflash.swf'>
  52. <param name='quality' value='High'>
  53. <param name='bgcolor' value='FFFFFF'>
  54. <param name='_cx' value='6350'>
  55. <param name='_cy' value='4339'>
  56. <param name='FlashVars' value>
  57. <param name='Src' value='images/tvflash.swf'>
  58. <param name='WMode' value='Window'>
  59. <param name='Play' value='-1'>
  60. <param name='Loop' value='-1'>
  61. <param name='SAlign' value>
  62. <param name='Menu' value='0'>
  63. <param name='Base' value>
  64. <param name='AllowScriptAccess' value='always'>
  65. <param name='Scale' value='ShowAll'>
  66. <param name='DeviceFont' value='0'>
  67. <param name='EmbedMovie' value='0'>
  68. <param name='SWRemote' value>
  69. <param name='MovieData' value>
  70. <param name='SeamlessTabbing' value='1'>
  71. <embed name='Movie1' src='images/tvflash.swf'
  72.  quality='high' bgcolor='#FFFFFF' swLiveConnect='true'
  73.  width='266' height='181'
  74.  type='application/x-shockwave-flash'
  75.  pluginspage='http://www.macromedia.com/go/getflashplayer'></embed></object>
  76. </td>
  77. </tr>
  78. <tr>
  79. <td width='100%' bgcolor='#5F7B2A'>
  80. <iframe src='subskrypcja.php?mode=formularz&language=".$language."' height='95' width='270' name='subscribe' align='texttop' border='0' frameborder='0' target='_blank' scrolling='no'></iframe>
  81. </td>
  82. </tr>
  83. </table>
  84. </td>
  85. <td width='65%' height='1' bgcolor='#5F7B2A'>
  86. <iframe src='home.php' height='246' width='470' name='I1' align='texttop' border='0' frameborder='0' target='_blank'></iframe></td>
  87. </tr>
  88. </table>
  89. </td>
  90. </tr>
  91. </table>
  92. </td>
  93. </tr>
  94. </table>
  95. </center>
  96. </div>
  97. ?>


problem powstaje przy pierwszej iframe, czyli:

<iframe src='subskrypcja.php?mode=formularz&language=".$language."' height='95' width='270' name='subscribe' align='texttop' border='0' frameborder='0' target='_blank' scrolling='no'></iframe>

w ten sposób udało mi się przesłać do pliku subskrypcja zmienną language, ale...

  1. <?php
  2.  
  3. /***************************************************************************
  4.  *  subscribe.tpl
  5.  * -------------------  
  6.  *  begin : 11.09.2005
  7.  *  copyright : (C) 2005 Miskiewicz Grzegorz
  8.  *  email : awcms@djmassive.com
  9.  *
  10.  ***************************************************************************/
  11.  
  12. include('include/startinclude.inc');
  13.  
  14. echo "<base target='_self'>";
  15.  
  16. if ($mode=='formularz')
  17. { include("language/$language.php"); // tutaj pobiera mi ładnie
  18. echo "<div align='center'>
  19.  <center>
  20. <table border='0' cellpadding='0' cellspacing='0' width='250' height='65' style='border-collapse: collapse' bordercolor='#111111'>
  21. <tr>
  22. <td width='100%'>
  23. <form method='POST' action='subskrypcja.php?mode=dodaj'>
  24. <p align='justify' class='tekst_small_5' style='margin-top: 0; margin-bottom: 0'>".$subscribe_info."</p>
  25. <p align='center' style='margin-bottom: 0; margin-top:10'>
  26. <input type='text' name='submail' size='38' style='font-family: Tahoma; font-size: 8pt'></p>
  27. <p align='center' style='margin-top: 10; margin-bottom: 0'>
  28. <input type='submit' value='dodaj' name='submit1' style='font-family: Tahoma; font-size: 8pt; font-variant: small-caps'>
  29. <input type='submit' value='wypisz' name='submit' style='font-family: Tahoma; font-size: 8pt; font-variant: small-caps'></p>
  30. </form>
  31. </td>
  32. </tr>
  33. </table>
  34. </center>
  35. </div>";
  36.  
  37. }
  38.  
  39. if ($mode=='dodaj')
  40. { include("language/$language.php"); //ale tutaj już nie :(
  41. $data=date('Y-m-d');
  42. $db=mysql_connect($dbh,$dbu,$dbp);
  43. $check="SELECT email FROM subskrypcja";
  44. $dane="INSERT INTO subskrypcja VALUES ('$submail','$data')";
  45. $wynik=mysql_query($check);
  46. while($row=mysql_fetch_array($wynik)) {
  47. if (($submail==$row['email']) || ($submail=='')) {
  48. $sad="0"; } else $sad="500"; }
  49.  
  50. if ($sad=="500") {
  51.  
  52. $db=mysql_connect($dbh,$dbu,$dbp);
  53. $wynik2=mysql_query($dane);
  54. echo "<p class='n2' align='center'>Adres: $submail został pomyślnie dodany. </p>";
  55.  } else echo "<p class='tekst_small_2' align='center'>".$subscribe_error."</p>";
  56.  
  57. }
  58.  
  59. if ($submit=='wypisz')
  60. {
  61.  $db=mysql_connect($dbh,$dbu,$dbp);
  62.  $check="SELECT * FROM subskrypcja";
  63.  
  64.  $wynik33=mysql_query($check);
  65.  while($row=mysql_fetch_array($wynik33)) {
  66.  
  67. if ($submail==$row['email']) { $sid="500"; } else $sid="0"; }
  68.  
  69. if ($sid=="500") {
  70. $mail=$submail; 
  71. $dane="DELETE FROM subskrypcja WHERE email='$mail'";
  72. echo "<p class='n2' align='center'>Adres: $mail został pomyślnie usunięty z bazy danych. Nie będziesz już od nas
     otrzymywał maili informacyjnych.</p>"
    ;
  73. $db=mysql_connect($dbh,$dbu,$dbp);
  74. mysql_select_db($dbn); $wynik2=mysql_query($dane); }
  75. else echo "<p class='n2' align='center'>Podany przez Ciebie adres : $submail, nie znajduje się w naszej bazie danych!
     </p>"
    ; exit;
  76.  
  77. }
  78.  
  79. ?>


jak to mam zrobić questionmark.gif
sf
nie widze session_start, pozatym nie lubie ramek, nie wiem po co je stosujecie..
djmassive
session_start(); dawałem, ale... na to samo mi wychodzi sad.gif zmiennej poprostu nie zapisuje, a ramki mi są niezbędne, gdyż wymieniam w nich podstrony - wiecie newsy itp. Nie widze innego rozwiązania, prosty przykład możecie zobaczyć na aktualnej stronie: www.djmassive.com. ja wpisywałem to tak z session start

<? session_start();
$_SESSION['zmienna'] = zmienna;

?>

no i pobierał mi ładnie $_SESSION['zmienna'] do czasu sad.gif - i co najlepsze, że zaraz po pierwszym załadowaniu się strony, w pierwszej ramce widzi zmienną, ale gdy klikne dodaj, nagle... szlak ją trafia sad.gif

wiem też że można by to cookie zapisać, ale jak questionmark.gif setcookie(); to juz znam, ale jak wpisywalem, nie widziałem, aby tworzył mi sie pliczek cookie na dysku sad.gif robie na krasnalu !
Kicok
Masz zablokowane w przeglądarce zapisywanie cookiesów, albo jakiś Firewall ci to blokuje. Pewnie dlatego nie działały ci też sesje - identyfikator sesji standardowo zapisywany jest w cookiesach ;]
djmassive
Używam FIREFOX'a, no i mam zezwolone ciastka itp... no ja nie wiem sam. Jeżeli ktoś wie, jak to rozwiązać, i raczy kodem rzucić przykładowym, będę nadwyraz wdzięczny
s_w_ir
Polecam do rozwiązania tego problemu zmontuj mniejszy kod, który uzględnia ten problem, a napewno znajdzie sie więcej osob które będą w stanie CI pomóc. Ja jak widze taki kod to za nic nie chce mi sie przez niego przedzierać. Myśle też że jak pomyślisz i zmontujesz mniejszy kod do testowania tego problemu, sam może go rozwiążesz. Pozdrawiam.
djmassive
Na chwile obecną poszedłem po lini prostej, i ominołem zmienną. Poprostu będą 2 katalogi tongue.gif polski i angielski i zduplikowane pliki - to jest chyba najlepszy sposób, jeżeli ktoś coś będzie wiedział, jak to z tymi ramkami i sesjami, to niech pisze exclamation.gif
h.4
Skorzystaj z Session Handlera (Własny moduł sesji) natomiast identyfikator sesji przesyłaj w zmiennej w adresie strony.

http://phpclasses.org
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.