login form on external page

Hi!

I have done 3 external pages.

In these pages I have cloned the same layout of my elgg.

These pages have static info and I have put in them also the login form if user is not logged yet.

Now if I try to login i read this error: "We encountered an error (token mismatch). This probably means that the page you were using expired. Please try again."

In the form I find 2 hidden field: __elgg_ts and __elgg_timestamp.

I think here is the problem. Searching on google I find some info about these 2 fields I find I have to initialize them in this way:

session_start();
require_once(dirname(__FILE__) . "/engine/start.php");
$ts = time();
$token = generate_action_token($ts);
But it gives me the same error! :(
Please how can I solve it?
Thanks
  • Hi!

    Thanks for your reply!

    I have the same problem using the form created in views/account/form/login.php created like the wiki article!

    This is the form:

    $form_body = "<p class=\"loginbox\"><label>" . elgg_echo('username') . "<br />" . elgg_view('input/text', array('internalname' => 'username', 'class' => 'login-textarea')) . "</label>";
        $form_body .= "<br />";
        $form_body .= "<label>" . elgg_echo('password') . "<br />" . elgg_view('input/password', array('internalname' => 'password', 'class' => 'login-textarea')) . "</label><br />";
        $form_body .= elgg_view('input/submit', array('value' => elgg_echo('login'))) . " <div id=\"persistent_login\"><label><input type=\"checkbox\" name=\"persistent\" value=\"true\" />".elgg_echo('user:persistent')."</label></div></p>";
        $form_body .= "<p class=\"loginbox\">";
        $form_body .= (!isset($CONFIG->disable_registration) || !($CONFIG->disable_registration)) ? "<a href=\"{$vars['url']}account/register.php\">" . elgg_echo('register') . "</a> | " : "";
        $form_body .= "<a href=\"{$vars['url']}account/forgotten_password.php\">" . elgg_echo('user:password:lost') . "</a></p>"; 
       
        //<input name=\"username\" type=\"text\" class="general-textarea" /></label>
       
        $login_url = $vars['url'];
        if ((isset($CONFIG->https_login)) && ($CONFIG->https_login))
            $login_url = str_replace("http", "https", $vars['url']);
    ?>
       
        <div id="login-box">
        <h2><?php echo elgg_echo('login'); ?></h2>
            <?php
                echo elgg_view('input/form', array('body' => $form_body, 'action' => "{$login_url}action/login"));
            ?>
           
        </div>

    And this is the error... :(

    We encountered an error (token mismatch). This probably means that the page you were using expired. Please try again.

    How can I solve it, plase?

    Thnaks

     

  • @bbg5ne : Just do a search for token mismatch in elgg wiki. You will get the solution.

    NB: Nexttime please look at the wiki, before you ask. The wiki will help you a lot.