Help - Search - Member List - Calendar
Full Version: problem with session
WorkTheWeb Forums > Webmaster Resources > PHP Help
Support our Sponsors!
SAN CAZIANO
My site has:

- 1 frame in top where I have some images to change the language of
the site if clicked

- 1 frame at left for the menu

- 1 frame at middle to load the page chosen in menu



in the index.php my code is

(i save in a var the name of the page displayed and the language active)



if(!isset($_SESSION['mainform']))

{

$_SESSION['mainform'] = "main.php";

}





if(!isset($_SESSION['language']))

{

$_SESSION['language'] = "ITA";

}





in the TopFrame my code is





<SCRIPT language="JavaScript">

function LanguageChange(language)

{

//i get the current viewed page


document.TopForm.main_form.value=parent.document.all.mainFrame.src;



//i change the site language

switch (language)

{

case 'ITA':


document.TopForm.selected_language.value='ITA';

<?php $_SESSION['language']='ITA'; ?>

break;

case 'ENG':


document.TopForm.selected_language.value='ENG';

<?php $_SESSION['language']= 'ENG'; ?>

break;

}

document.TopForm.submit();

}

</SCRIPT>



$TMPLAN=$_ SESSION ['language'];

echo"

<form name="TopForm">

<input name="selected_language" type="hidden" value="$TMPLAN">

<input name="main_form" type="hidden" value="main.php">

<table>

<tr>

<td>

&nbsp;<img src="../italiano.bmp" onClick="LanguageChange('ITA')">

</td>

<td>

&nbsp;<img src="../inglese.bmp" onClick="LanguageChange('ENG')">

</td>

</tr>

</table>

";





in una mia pagina che carico al FrameCentrale utilizzo queste istruzioni

(i have to read the variable of the 2 session or read the value in
document.TopForm.selected_language)

<?php

if ($_SESSION['language']=='ITA')

echo "testo italiano";

else

if ($_SESSION['language']=='ENG')

{

echo "testo inglese";

}

?>



the problem is that i can't change the language as i aspect.

Can anyone help me as soon as possible, please.

Stefan Rybacki
SAN CAZIANO wrote:
QUOTE
My site has:

-        1 frame in top where I have some images to change the language of
the site if clicked

-        1 frame at left for the menu

-        1 frame at middle to load the page chosen in menu



in the  index.php my code is

(i save in a var the name of the page displayed and the language active)



if(!isset($_SESSION['mainform']))

{

$_SESSION['mainform'] = "main.php";

}





if(!isset($_SESSION['language']))

{

$_SESSION['language'] = "ITA";

}





in the  TopFrame my code is





<SCRIPT language="JavaScript"

function LanguageChange(language)

{

//i get the current viewed page


document.TopForm.main_form.value=parent.document.all.mainFrame.src;



//i change the site language

switch (language)

{

case 'ITA':


document.TopForm.selected_language.value='ITA';

<?php              $_SESSION['language']='ITA';            ?

break;

case 'ENG':


document.TopForm.selected_language.value='ENG';

<?php              $_SESSION['language']= 'ENG';            ?

break;

}

document.TopForm.submit();

}

</SCRIPT



$TMPLAN=$_ SESSION ['language'];

echo"

<form name="TopForm"

<input name="selected_language" type="hidden" value="$TMPLAN"

<input name="main_form" type="hidden" value="main.php"

<table

<tr

<td

&nbsp;<img src="../italiano.bmp" onClick="LanguageChange('ITA')"

</td

<td

&nbsp;<img src="../inglese.bmp" onClick="LanguageChange('ENG')"

</td

</tr

</table

";





in una mia pagina che carico al FrameCentrale utilizzo queste istruzioni

(i have to read the variable of the 2 session or read the value in
document.TopForm.selected_language)

<?php

if ($_SESSION['language']=='ITA')

echo "testo italiano";

else

if ($_SESSION['language']=='ENG')

{

echo "testo inglese";

}

?



the problem is that i can't change the language as i aspect.

The problem is that PHP is server side and javascript is client side.
Have a look at your source after the top frame is loaded.
To change the language you to reload the top frame with for example a
GET parameter to the PHP script that changes the language.

Regards
Stefan

QUOTE

Can anyone help me as soon as possible, please.






PHP Help | Linux Help | Web Hosting | Reseller Hosting | SSL Hosting
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2006 Invision Power Services, Inc.