简体   繁体   中英

username and password help in joomla

What I'm trying to do here is display my login information and once logged in display something else

Example is here

    <?php
    $user = JFactory::getUser();
    $status = $user->guest;

    if($status == 1){
    echo '
   <form id="login-form" class="form-inline" method="post" action="/home">
   <div class="topUser">
        Name: 
        <input id="modlgn-username" class="TopinputReg" type="text" placeholder="User Name" tabindex="0" name="username" />
      </div>
      <div class="toppass">Password: 
        <input id="modlgn-passwd" class="TopinputReg" type="password" placeholder="Password" tabindex="0" name="password" pwfprops="," />
      </div>
      <div class="topsignin">
        <input class="Signin" name="Submit" tabindex="0" type="submit" value="" />
      </div>
      <div class="topregister">
        <a href="http://gamers-league.com/forums/user/register"><input name="button" type="submit" class="Register" id="button" value="" /></a>
              </div>
    <input type="hidden" value="com_users" name="option">
    <input type="hidden" value="user.login" name="task">
    <input type="hidden" value="aW5kZXgucGhwP0l0ZW1pZD0xMzM=" name="return">
    <input type="hidden" value="1" name="39ea5446d876078c6f6221d396ef5bd4">
              </form>
    ';
     }
    else
    {
    echo '
    <div class="topUser">Welcome Back!</div>
      <div class="toppass">Enjoy you stay.</div>
      <form id="login-form" class="form-vertical" method="post" action="/log-out">
      <div class="topsignin">
        <input class="Signout" type="submit" value="" name="Submit" />
        <input type="hidden" value="com_users" name="option">
              </div>
    <input type="hidden" value="com_users" name="option">
    <input type="hidden" value="user.logout" name="task">
    <input type="hidden" value="aW5kZXgucGhwP0l0ZW1pZD0xMDE=" name="return">
    <input type="hidden" value="1" name="994c61f8ab4ccf23fe9dae6546a87089">

      </form>
      <div class="topregister">
        <a href="http://gamers-league.com/forums/user"><input name="button" type="submit" class="account" id="button" value="" /></a>
      </div>
    ';
    }
    ?>

No I know what I am doing wrong just have no clue how to fix it. the two

need to have a different generated number each time but how do i do this.

since this numbers are the same every time if i log in then out then try to log back in it will give me "Invalid Token"

When i go into the login template it gives me this for login

<input type="hidden" name="return" value="<?php echo base64_encode($this->params->get('login_redirect_url', $this->form->getValue('return'))); ?>" />
<?php echo JHtml::_('form.token'); ?>

and this for log out

<input type="hidden" name="return" value="<?php echo base64_encode($this->params->get('logout_redirect_url', $this->form->getValue('return'))); ?>" />
<?php echo JHtml::_('form.token'); ?>

Now if I replace the hidden fields that already have the pregenerated numbers with the php stuff above when i try to refresh my page it goes completely blank.

I am at a loss with this see as how I am not very advanced in php. any help anyone cant provide would be massively helpful..

why not try like this,

  <?php
    $user = JFactory::getUser();
    $status = $user->guest;

    if($status == 1):
?>

<form id="login-form" class="form-inline" method="post" action="/home">
   <div class="topUser">
        Name: 
        <input id="modlgn-username" class="TopinputReg" type="text" placeholder="User Name" tabindex="0" name="username" />
      </div>
      <div class="toppass">Password: 
        <input id="modlgn-passwd" class="TopinputReg" type="password" placeholder="Password" tabindex="0" name="password" pwfprops="," />
      </div>
      <div class="topsignin">
        <input class="Signin" name="Submit" tabindex="0" type="submit" value="" />
      </div>
      <div class="topregister">
        <a href="http://gamers-league.com/forums/user/register"><input name="button" type="submit" class="Register" id="button" value="" /></a>
              </div>
    <input type="hidden" value="com_users" name="option">
    <input type="hidden" value="user.login" name="task">
    <input type="hidden" name="return" value="<?php echo base64_encode($this->params->get('login_redirect_url', $this->form->getValue('return'))); ?>" />
<?php echo JHtml::_('form.token'); ?>
              </form>

<?php else:
?>

<div class="topUser">Welcome Back!</div>
      <div class="toppass">Enjoy you stay.</div>
      <form id="login-form" class="form-vertical" method="post" action="/log-out">
      <div class="topsignin">
        <input class="Signout" type="submit" value="" name="Submit" />
        <input type="hidden" value="com_users" name="option">
              </div>
    <input type="hidden" value="com_users" name="option">
    <input type="hidden" value="user.logout" name="task">
    <input type="hidden" name="return" value="<?php echo base64_encode($this->params->get('logout_redirect_url', $this->form->getValue('return'))); ?>" />
<?php echo JHtml::_('form.token'); ?>

      </form>
      <div class="topregister">
        <a href="http://gamers-league.com/forums/user"><input name="button" type="submit" class="account" id="button" value="" /></a>
      </div>
<?php endif;?>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM