Jump to content

VaulX

New Members
  • Posts

    8
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

VaulX's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. By the way, I don't have session_start() in this code and it still works. I think it's because this script is being called from another script where session_start() already exists.
  2. Thanks, Andy... I managed to get my code working using sessions. What I've created is a language selector, either English or Vietnamese. Depending on which language the user selects it stores a session variable for it and then calls a PHP file where I have defined all my constants. I originally just assigned variables ( $user = "Vaulx"; ), but that didn't seem to work with another PHP script I downloaded to use as a form mailer. I had to "define" all of my variables/constants. This part I haven't figured, but I'm getting there. The following is the small piece of code I created to do three things: 1 - Checks if user selected the language button. 2 - Determines which language to use. 3 - Sets default language to English if first time visit. <?php // Check if user selected a language button and assign session variable. if ($_GET[lan] == 'vn') { $_SESSION['lan'] = 'vn'; } elseif ($_GET[lan] == 'en') { $_SESSION['lan'] = 'en'; } elseif (!isset($_SESSION['lan'])) { $_SESSION['lan'] = 'en'; } // Include the appropriate language file depending upon session variable set in previous step. if ($_SESSION['lan'] == 'vn') { include ('/.../language/vietnamese.php'); } elseif ($_SESSION['lan'] == 'en') { include ('/.../language/english.php'); } ?>
  3. Ok... So what's the difference between the "define" function and sessions? Or maybe I should ask what's the difference between assigning a variable ($a) and defining a constant with "define"?
  4. One more question regarding sessions... Once a session variable is set, can it be changed during the same session?
  5. I've read different methods of storing variables, but I have one question. How do you store a variable in memory to be used on any web page the user views? Do you use the "define" method for constants?
  6. Thanks, Abra... I noticed this method of passing information via URL addresses, but just not sure how I would proceed. At the beginning of every web page it would call a language.php file to determine which language to use. It would determine the correct language by what the global, constant variable is set to. I might have my terminology wrong so please feel free to correct me. I suppose it doesn't need to refresh the current screen but redirect them to the home page displaying the new language. Somehow the image buttons need to pass the language information to the home page via the URL trick you mentioned. Can the home page look for the value and use it if it's there?
  7. Hello, I'm new to PHP and have limited knowledge other than echoing, setting/defining constants and simple mathematics. I am developing a simple website that is to use the English and Vietnamese languages. Don't worry, my wife is doing all the Vietnamese translating. On another website I developed I used two images of flags as the language buttons at the top of the screen. This simply redirected you to either an EN or VN directory of the website. The problem is the website had to be created twice in these two directories. This time I have defined to PHP language files. Each file has the same variables/constants defined using "define" but with different values, either English or Vietnamese. All the web pages echo the corresponding constant to display the text/value. Each web page uses the "include" command at the top of the web page. What I want are push buttons at the top of the screen that defines what a language variable for each web page to use. The push buttons are simple English or Vietnamese flags that I use CSS to create. I feel I'm so close, but I just can't figure out how to reassign a variable and cause the screen to refresh with the new language. Any help will be greatly appreciated. Thanks
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.