Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

STS Template help - login / logout button


richm

Recommended Posts

Hiya!

 

I've been trying something out with STS 1.8.

 

Basically my site: nettik.co.uk is all going great, apart from one thing. on the menu bar, I am trying to add a button that will detect whether you are logged in or logged out; and then display the according relevant button. Eg user is logged in, menu item is "log off" which points to 'logoff.php' file.

 

I started by renaming the sts_template.html file to sts_template.php to give me some dynamic functionality, and then updated configure.php accordingly.

 

I then made a quick IF statement to display a text link depending on their statement:

 

<?php 
$sessionid = $HTTP_GET_VARS['osCsid'];

if ( $sessionid == "" ) {
echo('<a href="login.php">login</a>');
} else {
echo('<a href="logoff.php">logout</a>');
}
?>

 

and added this code in one of the table cells where the images would eventually sit once the code was sorted.

 

However, when you look at the page live, instead of a text link, you get elements of the PHP code printed out !! ??

 

Also, i don't think the code is working either, because even when you're logged off, and the intro text says: "welcome! You're currently a Guest!" the result of the IF statement above outputs the 'logoff.php' option of the statement.

 

Any help would be greatly appreciated.

 

I have also insterted a link here to a downloadable version of my STS template.

 

Thx in advance, really need help !

 

Rich

Link to comment
Share on other sites

Hello,

 

You can't use PHP in the STS template file; it doesn't get read that way. If you want to do something like that, you would be better off with the BTS or just editing the files without a template system. In this case though, I don't think that you need to put the code there. Just make a new box that holds the link that you want and put the code in the box. I suspect that you can find an example of this in the main STS support thread.

 

Hth,

Matt

Always back up before making changes.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...