This website can use cookies to improve the user experience

This website can use cookies to improve the user experience and to provide certain services and functions to users. Cookies contain small amounts of information (such as login information and user preferences) and will be stored on your device.

Enable All Cookies Privacy Policy

Fiddling around with registration and PHP variables


avatar
digibri 0
From: -
Fiddling around with registration and PHP variables

Hello,

I'm rearranging stuff, specifically the registration pages - yeah I know, will it never end? Winking Face

Among other things, what I'm trying to do is create a new version of the User menu that has a username and a password entry box as part of it's default makeup. Part of this should also include the variable, $insert[login_name] to indicate if the visitor is already logged in and under what username.

I copied the above variable call from the "login_header_user.php" template and in addition, would also like to display the usergroup of the logged in user as well.

However, when I place $insert[login_name] in the "site_header.php" template, it doesn't resolve to the logged in user account name.


Any thoughts?

B.

Notice

This topic is archived. New comments cannot be posted and votes cannot be cast.

Responses to this topic


1 Re: Fiddling around with registration and PHP variables
avatar
Administrator
1340
From: Vienna, Austria
Fiddling around with registration and PHP variables

The variable $insert[login_name] is not used in the site_header template.

Instead, add the following PHP code between global $insert; and $EST_TEMPLATE = <<<TEMPLATE:

//Get user data from cookie and put it in $userdata array

$userdata = explode(":!:",base64_decode($_COOKIE['esselbachst']));

//If the user is not logged in (e.g. $userdata[0] is empty)
if (!$userdata[0]) {
$usermenu = <<<HTMLOUTPUT
<table cellspacing="1" cellpadding="3" width="160" border="0">
<tr>
<td bgcolor="#008000">
<font face="Arial" color="#ffffff" size="2"><b>Hello Anonymous</b></font></td>
</tr>
<tr>
<td bgcolor="#ffffff"><font size="2">
Please login
</font></td>
</tr>
</table>
<br />
HTMLOUTPUT;

//User logged in?
} else {

$usermenu = <<<HTMLOUTPUT
<table cellspacing="1" cellpadding="3" width="160" border="0">
<tr>
<td bgcolor="#008000">
<font face="Arial" color="#ffffff" size="2"><b>Welcome back!</b></font></td>
</tr>
<tr>
<td bgcolor="#ffffff"><font size="2">
Hello $userdata[0]
</font></td>
</tr>
</table>
<br />
HTMLOUTPUT;
}


The script is getting the login data from the cookie. Then it prints a login menu in the variable $usermenu

$usermenu can be used everywhere on the template. $userdata[0] is the actual login name.

Notice

This topic is archived. New comments cannot be posted and votes cannot be cast.