Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Login and Log out problem.


phillife76

Recommended Posts

Hi Everyone,

 

i am very new to Oscommerce and i m using the sample template as testing. But i dont see a logout box or tab for the end user to logout in the template. How do i create it? Please advice or point me to any reference guide or site that i can get some guide from.

 

Thanks

Link to comment
Share on other sites

Add this to your top links:

 

<?php if (tep_session_is_registered('customer_id')) { ?><a href="<?php echo tep_href_link(FILENAME_LOGOFF, '', 'SSL'); ?>"><?php echo HEADER_TITLE_LOGOFF; ?></a> <?php } else { ?><a href="<?php echo tep_href_link(FILENAME_LOGIN, '', 'SSL'); ?>"><?php echo HEADER_TITLE_LOGIN; ?></a><?php } ?>

Link to comment
Share on other sites

Add this to your top links:

 

<?php if (tep_session_is_registered('customer_id')) { ?><a href="<?php echo tep_href_link(FILENAME_LOGOFF, '', 'SSL'); ?>"><?php echo HEADER_TITLE_LOGOFF; ?></a> <?php } else { ?><a href="<?php echo tep_href_link(FILENAME_LOGIN, '', 'SSL'); ?>"><?php echo HEADER_TITLE_LOGIN; ?></a><?php } ?>

 

Hi Spax,

 

thanks for showing the code here. For this code, which php at which folder should i be adding? and at the top of the file itself? Forgive me as i m totally new to php.

 

thanks

Link to comment
Share on other sites

In your includes/header.php you will see similar links to that, for home, hardware, software, DVD, your cart, shipping all nested in a table cell <td></td>

 

Make a copy of the file first!!! Then add the code I posted in those links. If it looks too confusing, post the contents of that cell here and I'll included the code for you.

 

Remember, make a copy of the file first. That way, if you completely mess it up and we've all done that, you can easily get back to where you are now.

Link to comment
Share on other sites

In your includes/header.php you will see similar links to that, for home, hardware, software, DVD, your cart, shipping all nested in a table cell <td></td>

 

Make a copy of the file first!!! Then add the code I posted in those links. If it looks too confusing, post the contents of that cell here and I'll included the code for you.

 

Remember, make a copy of the file first. That way, if you completely mess it up and we've all done that, you can easily get back to where you are now.

 

 

Hi , i managed to add in the code. But the placing is not right. can teach how how do i make it in the same line as the "Hardware, software, etc ? I had paste my code as below. Website as at : http://pc2k.freehostia.com/shop/6057/index.php

 

 

<?php

/*

$Id: header.php,v 1.42 2003/06/10 18:20:38 hpdl Exp $

 

osCommerce, Open Source E-Commerce Solutions

http://www.oscommerce.com

 

Copyright © 2003 osCommerce

 

Released under the GNU General Public License

*/

 

// check if the 'install' directory exists, and warn of its existence

if (WARN_INSTALL_EXISTENCE == 'true') {

if (file_exists(dirname($HTTP_SERVER_VARS['SCRIPT_FILENAME']) . '/install')) {

$messageStack->add('header', WARNING_INSTALL_DIRECTORY_EXISTS, 'warning');

}

}

 

// check if the configure.php file is writeable

if (WARN_CONFIG_WRITEABLE == 'true') {

if ( (file_exists(dirname($HTTP_SERVER_VARS['SCRIPT_FILENAME']) . '/includes/configure.php')) && (is_writeable(dirname($HTTP_SERVER_VARS['SCRIPT_FILENAME']) . '/includes/configure.php')) ) {

$messageStack->add('header', WARNING_CONFIG_FILE_WRITEABLE, 'warning');

}

}

 

// check if the session folder is writeable

if (WARN_SESSION_DIRECTORY_NOT_WRITEABLE == 'true') {

if (STORE_SESSIONS == '') {

if (!is_dir(tep_session_save_path())) {

$messageStack->add('header', WARNING_SESSION_DIRECTORY_NON_EXISTENT, 'warning');

} elseif (!is_writeable(tep_session_save_path())) {

$messageStack->add('header', WARNING_SESSION_DIRECTORY_NOT_WRITEABLE, 'warning');

}

}

}

 

// check session.auto_start is disabled

if ( (function_exists('ini_get')) && (WARN_SESSION_AUTO_START == 'true') ) {

if (ini_get('session.auto_start') == '1') {

$messageStack->add('header', WARNING_SESSION_AUTO_START, 'warning');

}

}

 

if ( (WARN_DOWNLOAD_DIRECTORY_NOT_READABLE == 'true') && (DOWNLOAD_ENABLED == 'true') ) {

if (!is_dir(DIR_FS_DOWNLOAD)) {

$messageStack->add('header', WARNING_DOWNLOAD_DIRECTORY_NON_EXISTENT, 'warning');

}

}

 

if ($messageStack->size('header') > 0) {

echo $messageStack->output('header');

}

 

 

?>

<div style="height:21px; "></div>

<table width="715" border="0" cellspacing="0" cellpadding="0" align="center">

<tr>

<td width="6%"><a href="<?php echo tep_href_link(FILENAME_DEFAULT); ?>"><img src="<?php echo DIR_WS_IMAGES ?>theme/logo.jpg" width="177" height="59" border="0"></a></td>

<td width="94%" valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0">

<tr>

<td align="right"><img src="<?php echo DIR_WS_IMAGES ?>theme/call.jpg" width="184" height="35"></td>

</tr>

<tr>

<td><table width="100%" border="0" cellpadding="0" cellspacing="0" background="<?php echo DIR_WS_IMAGES ?>theme/ui.jpg">

<tr>

<td width="26%"><em><img src="<?php echo DIR_WS_IMAGES ?>theme/ui.jpg" width="1" height="24"></em></td>

 

<td width="100%">

 

<span class="style1"><a href="<?php echo tep_href_link(FILENAME_DEFAULT); ?>" class="top" style="color:#FFFFFF;text-decoration:none">home</a>

  |  <a href="<?php echo tep_href_link(FILENAME_DEFAULT,'cPath=1'); ?>" class="top" style="color:#FFFFFF;text-decoration:none">hardware</a>

  |  <a href="<?php echo tep_href_link(FILENAME_DEFAULT,'cPath=2'); ?>" class="top" style="color:#FFFFFF;text-decoration:none">software</a>

  |   <a href="<?php echo tep_href_link(FILENAME_DEFAULT,'cPath=3'); ?>" class="top" style="color:#FFFFFF;text-decoration:none">DVD</a>

 |  <a href="<?php echo tep_href_link(FILENAME_SHOPPING_CART); ?>" class="top" style="color:#FFFFFF;text-decoration:none">your cart</a>

  |  <a href="<?php echo tep_href_link(FILENAME_SHIPPING); ?>" class="top" style="color:#FFFFFF;text-decoration:none">shipping</a>  | 

<?php if (tep_session_is_registered('customer_id')) { ?><a href="<?php echo tep_href_link(FILENAME_LOGOFF, '', 'SSL'); ?>" class="top" style="color:#FFFFFF;text-decoration:none"><?php echo HEADER_TITLE_LOGOFF; ?></a></span> <?php } else { ?><a href="<?php echo tep_href_link(FILENAME_LOGIN, '', 'SSL'); ?>"><?php echo HEADER_TITLE_LOGIN; ?></a></span><?php } ?>

 

 

 

</td>

</tr>

</table></td>

</tr>

</table></td>

</tr>

</table>

 

<?php

if (isset($HTTP_GET_VARS['error_message']) && tep_not_null($HTTP_GET_VARS['error_message'])) {

?>

<table border="0" width="100%" cellspacing="0" cellpadding="2">

<tr class="headerError">

<td class="headerError"><?php echo htmlspecialchars(urldecode($HTTP_GET_VARS['error_message'])); ?></td>

</tr>

</table>

<?php

}

 

if (isset($HTTP_GET_VARS['info_message']) && tep_not_null($HTTP_GET_VARS['info_message'])) {

?>

<table border="0" width="100%" cellspacing="0" cellpadding="2">

<tr class="headerInfo">

<td class="headerInfo"><?php echo htmlspecialchars($HTTP_GET_VARS['info_message']); ?></td>

</tr>

</table>

<?php

}

?>

 

 

Thanks!

Link to comment
Share on other sites

I won't post into that code because if you use it all, you will lose all indentation in the file. Which will make it more difficult to edit the next time.

 

It's a simple fix though. In the cell where you have placed the new Log In link and the one above, you have width attributes of 26% and 100%. That is incorrect, as it adds to 126% but they aren't really necessary anyway, unless you want the links right justified. If you remove those attributes, the links will line up but if you want them over to the right side, then adjust the percentages to suit. i.e.

 

The top cell, change from:

 

 <td width="26%"><em><img src="<?php echo DIR_WS_IMAGES ?>theme/ui.jpg" width="1" height="24"></em></td>

 

to

 

 <td width="5%"><em><img src="<?php echo DIR_WS_IMAGES ?>theme/ui.jpg" width="1" height="24"></em></td>

 

and the cell that contains the links, change from:

 

<td width="100%">

 

to

 

<td width="95%">

 

After that, you can adjust them to what looks best for you. Just keep the total widths to 100%.

Link to comment
Share on other sites

I won't post into that code because if you use it all, you will lose all indentation in the file. Which will make it more difficult to edit the next time.

 

It's a simple fix though. In the cell where you have placed the new Log In link and the one above, you have width attributes of 26% and 100%. That is incorrect, as it adds to 126% but they aren't really necessary anyway, unless you want the links right justified. If you remove those attributes, the links will line up but if you want them over to the right side, then adjust the percentages to suit. i.e.

 

The top cell, change from:

 

 <td width="26%"><em><img src="<?php echo DIR_WS_IMAGES ?>theme/ui.jpg" width="1" height="24"></em></td>

 

to

 

 <td width="5%"><em><img src="<?php echo DIR_WS_IMAGES ?>theme/ui.jpg" width="1" height="24"></em></td>

 

and the cell that contains the links, change from:

 

<td width="100%">

 

to

 

<td width="95%">

 

After that, you can adjust them to what looks best for you. Just keep the total widths to 100%.

 

Dear Spax

 

Hi

 

I have a similar problem to phillilife76's, i.e. i want to place a log off option....

 

I am totally new to all this and have no clue whatsoever at working with .php files. I tried to place the code as you told phillilife76 but nothing changed.

 

I would be highly grateful if you could help me out. For your reference i am pasting the code of my header.php file as under

 

 

 

<?php

/*

$Id: header.php,v 1.19 2002/04/13 16:11:52 hpdl Exp $

 

osCommerce, Open Source E-Commerce Solutions

http://www.oscommerce.com

 

Copyright © 2002 osCommerce

 

Released under the GNU General Public License

*/

 

if ($messageStack->size > 0) {

echo $messageStack->output();

}

?>

<table border="0" width="100%" cellspacing="0" cellpadding="0">

<tr>

<td><?php echo tep_image(DIR_WS_IMAGES . 'oscommerce.gif', 'osCommerce', '204', '50'); ?></td>

<td align="right"><?php echo '<a href="http://www.boundlesstech.net" target="_blank">' . tep_image(DIR_WS_IMAGES . 'header_support.gif', HEADER_TITLE_SUPPORT_SITE, '50', '50') . '</a> <a href="' . tep_catalog_href_link() . '">' . tep_image(DIR_WS_IMAGES . 'header_checkout.gif', HEADER_TITLE_ONLINE_CATALOG, '53', '50') . '</a> <a href="' . tep_href_link(FILENAME_DEFAULT, '', 'NONSSL') . '">' . tep_image(DIR_WS_IMAGES . 'header_administration.gif', HEADER_TITLE_ADMINISTRATION, '50', '50') . '</a>'; ?> </td>

</tr>

<tr class="headerBar">

<td class="headerBarContent"> <?php echo '<a href="' . tep_href_link(FILENAME_DEFAULT, '', 'NONSSL') . '" class="headerLink">' . HEADER_TITLE_TOP . '</a>'; ?></td>

<td class="headerBarContent" align="right"><?php echo '<a href="http://www.boundlesstech.net" class="headerLink">' . HEADER_TITLE_SUPPORT_SITE . '</a> | <a href="' . tep_catalog_href_link() . '" class="headerLink">' . HEADER_TITLE_ONLINE_CATALOG . '</a> | <a href="' . tep_href_link(FILENAME_DEFAULT, '', 'NONSSL') . '" class="headerLink">' . HEADER_TITLE_ADMINISTRATION . '</a>'; ?> </td>

</tr>

</table>

 

 

 

Now i want to replace this "Support Site" text with "Log off" . Kindly help me with this....

 

Thanks a lot! :rolleyes:

Link to comment
Share on other sites

Now i want to replace this "Support Site" text with "Log off" . Kindly help me with this....

 

Replace this:

 

<td class="headerBarContent" align="right"><?php echo '<a href="http://www.boundlesstech.net" class="headerLink">' . HEADER_TITLE_SUPPORT_SITE . '</a> | <a href="' . tep_catalog_href_link() . '" class="headerLink">' . HEADER_TITLE_ONLINE_CATALOG . '</a> | <a href="' . tep_href_link(FILENAME_DEFAULT, '', 'NONSSL') . '" class="headerLink">' . HEADER_TITLE_ADMINISTRATION . '</a>'; ?> </td>

 

with this:

 

<td class="headerBarContent" align="right"><?php if (tep_session_is_registered('customer_id')) { ?><a class="headerLinks" href="<?php echo tep_href_link(FILENAME_LOGOFF, '', 'SSL'); ?>"><?php echo HEADER_TITLE_LOGOFF; ?></a> <?php } else { ?><a class="headerLinks" href="<?php echo tep_href_link(FILENAME_LOGIN, '', 'SSL'); ?>"><?php echo HEADER_TITLE_LOGIN; ?></a><?php } ?><?php echo ' | <a href="' . tep_catalog_href_link() . '" class="headerLink">' . HEADER_TITLE_ONLINE_CATALOG . '</a> | <a href="' . tep_href_link(FILENAME_DEFAULT, '', 'NONSSL') . '" class="headerLink">' . HEADER_TITLE_ADMINISTRATION . '</a>'; ?> </td>

 

 

Unless you have added your own functions, this:

 

tep_catalog_href_link()

 

should be this:

 

tep_href_link()

 

and it should have at least one argument - the file name

 

tep_href_link(FILENAME_DEFAULT)

 

If it isn't a function you have added, it will throw an error. Likewise if it doesn't have the file name, it will also throw an error.

Link to comment
Share on other sites

Thanks Peter,

 

You really help and increase my confidence of plunging into occommerce n php thot i know nothing about them.

 

Thanks

 

Phil,

 

You are welcome but what have you done to that logo? :D

Link to comment
Share on other sites

Phil,

 

You are welcome but what have you done to that logo? :D

 

O, heheh i just just doing some testing as it is a test site. But i am having some problem with my new installation after purchasing a new template, can you help? it is over here:

 

http://www.oscommerce.com/forums/index.php?showtopic=272893

 

Thanks in advance.

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...