0

Maybe I'm not doing the right question, or I'm not expressing myself very clear or accurately...

The problem is next:

file1.php

......
require_once "locales/" . $_SESSION['lang'] . ".php";
......

locales/en.php

<?php
$lang = array(
"text1" => "Access",
        );
?>

file2.php

......
include ('file1.php');
......
// User is not logged in, display one of the forms
private function form($error,$formname) {
    // Throttle failed attempts
    if($formname == 'signin' && $error != 0)
        sleep(1);

    // Show a sign up or sign in link in the navigation
    if($formname == 'signin')
        $link = '<p><a href="?form=signup">Create new account</a></p>';
    else
        $link = '<p><a href="'.$this->clean_uri().'">Access</a></p>';

......

So I need to change the "Access" word to the variable that inserts the word from the en.php file, but after trying many syntaxes I couldn't succeed, what's the way to do it?

Things I've tried:

$link = '<p><a href="'.$this->clean_uri().'">'.$lang['text1'].'</a></p>';


$link = '<p><a href="'.$this->clean_uri().'">'.$lang["text1"].'</a></p>';


$link = '<p><a href="'.$this->clean_uri().'">'.$lang[text1].'</a></p>';

and some more...

[SOLUTION] I finally found how to solve this:

At file2.php, after the include line I recover the variable this way:

$_POST['text1'] = $lang['text1'];

and then, inside the function I recover it like this:

// User is not logged in, display one of the forms
    private function form($error,$formname) {
        // Throttle failed attempts
        if($formname == 'signin' && $error != 0)
            sleep(1);

    // Show a sign up or sign in link in the navigation
    if($formname == 'signin')
        $link = '<p><a href="?form=signup">Create new account</a></p>';
    else
        $link = '<p><a href="'.$this->clean_uri().'">" .$_POST['text1']. "</a></p>';
Andrés Chandía
  • 999
  • 1
  • 16
  • 32

0 Answers0