Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Display admin name instead of username


drew020

Recommended Posts

added 2 extra feilds first name and last name when create new admin account

it all went well but when i tried to display the first name, it alway showing the same name

 

i want to display admin first name as greeting on the index.php after login, its keep showing the same name

 

am i missing something here?

 

<?php

$adminname_query = tep_db_query("select id, user_name, admin_fname, admin_lname from " . TABLE_ADMINISTRATORS );

if ($adminname = tep_db_fetch_array($adminname_query)) {

echo $adminname['admin_fname'];

}

?>

Link to comment
Share on other sites

There are 2 files to edit for this. This is based on field names above.

 

First, admin/login.php

To add your 2 new fields find

	  $check_query = tep_db_query("select id, user_name, user_password from " . TABLE_ADMINISTRATORS . " where user_name = '" . tep_db_input($username) . "'");

Change to

	  $check_query = tep_db_query("select id, user_name, user_password, admin_fname, admin_lname from " . TABLE_ADMINISTRATORS . " where user_name = '" . tep_db_input($username) . "'");

Add the 2 new tields to the admin session array. Find

		  $admin = array('id' => $check['id'],
						 'username' => $check['user_name']);

Change to


		  $admin = array('id' => $check['id'],
						 'username' => $check['user_name'],
						 'first_name' => $check['admin_fname'],
						 'last_name' => $check['admin_lname']);

In admin/includes/header.php find

<td class="headerBarContent" align="right"><?php echo (tep_session_is_registered('admin') ? 'Logged in as: ' . $admin['username']  . ' (<a href="' . tep_href_link(FILENAME_LOGIN, 'action=logoff') . '" class="headerLink">Logoff</a>)' : ''); ?>  </td>

Change this part of the above

$admin['username']

To

$admin['first_name']

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...