Jump to content

Login/Logout button PHP


skid

Recommended Posts

Pls Help I'm going crazy searched the net for two days know can't find the answer that is probably so easy  ::)

 

Ok here is is:

I work with joomla and i am building a website for a client, I have a login form that will pop up in a lightbox and it all works.

 

Now I am trying to change the PHP code so that when a user tries to login and click login (or logout) that it will go to the parent page

becouse now it stays in my lightbox which is way to small ofcourse.

 

Here is my PHP:

<?php
/**
* YOOlogin Joomla! Module
*
* @author    yootheme.com
* @copyright Copyright (C) 2007 YOOtheme Ltd. & Co. KG. All rights reserved.
* @license	 GNU/GPL
*/

// no direct access
defined('_JEXEC') or die('Restricted access');
?>

<?php if($type == 'logout') : ?>
<form action="index.php" method="post" name="login">
<?php else : ?>
<?php if(JPluginHelper::isEnabled('authentication', 'openid')) :
	$lang->load( 'plg_authentication_openid', JPATH_ADMINISTRATOR );
	$langScript = 	'var JLanguage = {};'.
					' JLanguage.WHAT_IS_OPENID = \''.JText::_( 'WHAT_IS_OPENID' ).'\';'.
					' JLanguage.LOGIN_WITH_OPENID = \''.JText::_( 'LOGIN_WITH_OPENID' ).'\';'.
					' JLanguage.NORMAL_LOGIN = \''.JText::_( 'NORMAL_LOGIN' ).'\';'.
					' var modlogin = 1;';
	$document = &JFactory::getDocument();
	$document->addScriptDeclaration( $langScript );
	JHTML::_('script', 'openid.js');
endif; ?>
<form action="<?php echo JRoute::_( 'index.php', true, $params->get('usesecure')); ?>" method="post" name="login">
<?php endif; ?>

<span class="<?php echo $style ?>" style="display: block;">
<span class="yoo-login">

	<?php if($type == 'logout') : ?>
	<span class="logout">

		<?php if ($params->get('greeting')) : ?>
		<span class="greeting"><?php echo JText::sprintf( 'HINAME', $user->get('name') ); ?></span>
		<?php endif; ?>

		<span class="logout-button">
			<button value="<?php echo JText::_( 'BUTTON_LOGOUT'); ?>" name="Submit" type="submit" title="<?php echo JText::_('BUTTON_LOGOUT'); ?>"><?php echo JText::_( 'BUTTON_LOGOUT'); ?></button>
		</span>

		<input type="hidden" name="option" value="com_user" />
		<input type="hidden" name="task" value="logout" />
		<input type="hidden" name="return" value="<?php echo $return; ?>" />

	</span>

	<?php else : ?>
	<span class="login">

		<?php echo $params->get('pretext'); ?>

		<span class="username">

			<input type="text" name="username" size="18" value="<?php echo JText::_( 'Username' ); ?>" onblur="if(this.value=='') this.value='<?php echo JText::_( 'Username' ); ?>';" onfocus="if(this.value=='<?php echo JText::_( 'Username' ); ?>') this.value='';" />

		</span>

		<span class="password">

			<input type="password" name="passwd" size="10" value="<?php echo JText::_( 'Password' ); ?>" onblur="if(this.value=='') this.value='<?php echo JText::_( 'Password' ); ?>';" onfocus="if(this.value=='<?php echo JText::_( 'Password' ); ?>') this.value='';" />

		</span>

		<?php if(JPluginHelper::isEnabled('system', 'remember')) : ?>
		<input type="hidden" name="remember" value="yes" />
		<?php endif; ?>

		<span class="login-button">
			<button value="<?php echo JText::_( 'BUTTON_LOGIN'); ?>" name="Submit" type="submit" title="<?php echo JText::_('BUTTON_LOGIN'); ?>"><?php echo JText::_( 'BUTTON_LOGIN'); ?></button>
		</span>

		<?php if ( $lost_password ) { ?>
		<span class="lostpassword">
			<a href="<?php echo JRoute::_( 'index.php?option=com_user&view=reset' ); ?>" title="<?php echo JText::_('FORGOT_YOUR_PASSWORD'); ?>" TARGET="_parent"></a>
		</span>
		<?php } ?>

		<?php if ( $lost_username ) { ?>
		<span class="lostusername">
			<a href="<?php echo JRoute::_( 'index.php?option=com_user&view=remind' ); ?>" title="<?php echo JText::_('FORGOT_YOUR_USERNAME'); ?>" TARGET="_parent"></a>
		</span>
		<?php } ?>

		<?php
		$usersConfig = &JComponentHelper::getParams( 'com_users' );
		if ($usersConfig->get('allowUserRegistration') && $registration) { ?>
		<span class="registration">
			<a href="<?php echo JRoute::_( 'index.php?option=com_user&view=register' ); ?>" title="<?php echo JText::_( 'REGISTER'); ?>"></a>
		</span>
		<?php } ?>

		<?php echo $params->get('posttext'); ?>

		<input type="hidden" name="option" value="com_user" />
		<input type="hidden" name="task" value="login" />
		<input type="hidden" name="return" value="<?php echo $return; ?>" />
		<?php echo JHTML::_( 'form.token' ); ?>

	</span>

	<?php endif; ?>

</span>
</span>
</form>

 

As you can see the "Forgot_YOUR_PASSWORD" and "FORGOT_YOUR_USERNAME" are already done, that wasn't a real problem.

Probably it has to be done with javascript, and allready tried some things but nothing worked so far.

 

Thanks in advance and I hope someone can help me soon.

Nick

Link to comment
https://forums.phpfreaks.com/topic/240174-loginlogout-button-php/
Share on other sites

Sorry, I'm new on the Forum and have been reading some more here,

I've noticed that when I want more accurate help I have to put the more relevent code

So here we go:

<span class="login-button">
<button value="<?php echo JText::_( 'BUTTON_LOGIN'); ?>" name="Submit" type="submit" title="<?php echo JText::_('BUTTON_LOGIN'); ?>"><?php echo JText::_( 'BUTTON_LOGIN'); ?></button>
</span>

 

And

 

<span class="logout-button">
<button value="<?php echo JText::_( 'BUTTON_LOGOUT'); ?>" name="Submit" type="submit" title="<?php echo JText::_('BUTTON_LOGOUT'); ?>"><?php echo JText::_( 'BUTTON_LOGOUT'); ?></button>
</span>

 

What I am trying to accomplish is to create a target=parent for these 2 buttons.

 

sorry for posting twice but maybe get more responses this way (atleast that's what I've read on the forum)

 

Thanks in advance

Nick

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.