Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls
 

A member login/logout auth box on non-xcart pages

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions
 
Thread Tools Search this Thread
  #1  
Old 07-16-2004, 10:25 AM
  Jon's Avatar 
Jon Jon is offline
 

X-Guru
  
Join Date: Oct 2002
Location: Vancouver, Canada
Posts: 4,200
 

Default A member login/logout auth box on non-xcart pages

I've seen several requests for the ability to have a login/logout auth box on websites that have their website seperate from their store.

This script simply includes the login box, allowing them to login to the store, and shows the logout box when they are already logged in.

It grabs the login variable, so you could expand this further on your pages by doing php mysql queries to do database manipulation with it.

Requirements:

- This is tested to work on 3.5.8 and I'm not sure if it works on any others.
- It assumes that your website pages are in a folder underneath the customer folder
(if it is not you must change the path of the require auth.php line)
- The page you want the box to appear on must parse php

Usage:

- Copy the code below and paste into a file called loginscript.php
- Upload the file to web server
- Open the page you want the box to appear on, and include the loginscript.php

The code will look something like:

Code:
<? include "/path/to/loginscript.php"; ?>

That's it. Here's the code:

Code:
<? #===========================================================================================# # # # X-CART LOGIN INTEGRATION - Jon Peters # # This script allows you to put a login/logout box on your non-xcart pages # # The $login variable can be used to pull further information from the database # # # # Created July 16, 2004 # # # #===========================================================================================# # # # USAGE: # # # # Edit the style config variables below to match your site look # # Save this code as loginscript.php and upload to your server # # Include the file on your php pages (using a php include) where you want the box to appear # # # #===========================================================================================# #--------------------------------------------- # REQUIRE X-CART INFORMATION #--------------------------------------------- require_once "./customer/auth.php"; #--------------------------------------------- # STYLE VARIABLES (Configure These) #--------------------------------------------- $bar_backgroundcolor = "#18409A"; $bar_font_face = "Arial"; $bar_font_color = "#FFFFFF"; $bar_font_size = "2"; $text_font_face = "Verdana"; $text_font_color = "#000000"; $text_font_size = "1"; $width = "150"; ?> <? #--------------------------------------------- # SHOW LOG IN #--------------------------------------------- if (!$login) { ?> <table border="0" cellpadding="5" cellspacing="0" width="<?= $width; ?>"> <tr> <td bgcolor="<?= $bar_backgroundcolor; ?>" height="26" width="100%"><font face="<?= $bar_font_face; ?>" color="<?= $bar_font_color; ?>" size="<?= $bar_font_size; ?>">Member Login</font></td> </tr> <tr> <td colspan="2"> <table border="0" cellpadding="0" cellspacing="0" width="100%"> <FORM action="/include/login.php" method=post name=authform> <input type="hidden" name="xid" value="<?= $XCARTSESSID; ?>"> <tr> <td><font face="<?= $text_font_face; ?>" color="<?= $text_font_color; ?>" size="<?= $text_font_size; ?>">Username</font> <input type="text" name="username" size="16"> <font face="<?= $text_font_face; ?>" color="<?= $text_font_color; ?>" size="<?= $text_font_size; ?>">Password</font> <input type="password" name="password" size="16"> <input type="hidden" name="mode" value="login"> <input type="hidden" name="usertype" value="C"> <input type="hidden" name="redirect" value="customer"></td> </tr> <tr> <td height="24"> <a href="javascript: document.authform.submit()"> <font face="<?= $text_font_face; ?>" color="<?= $text_font_color; ?>" size="<?= $text_font_size; ?>">Login </font><input type="image" src="/skin1/images/go_menu.gif" width="27" height="14" border="0" align="absmiddle"></a> </td> </tr> <tr> <td height="24" align="center"> <font face="<?= $text_font_face; ?>" color="<?= $text_font_color; ?>" size="<?= $text_font_size; ?>">Register</font> <font face="<?= $text_font_face; ?>" color="<?= $text_font_color; ?>" size="<?= $text_font_size; ?>">|</font> <font face="<?= $text_font_face; ?>" color="<?= $text_font_color; ?>" size="<?= $text_font_size; ?>">Lost Pass?</font></td> </tr> </form> </table> </td> </tr> </table> <? #--------------------------------------------- # SHOW LOG OUT #--------------------------------------------- } else { ?> <table border="0" cellpadding="5" cellspacing="0" width="<?= $width; ?>"> <tr> <td bgcolor="<?= $bar_backgroundcolor; ?>" height="26" width="100%"><font face="<?= $bar_font_face; ?>" color="<?= $bar_font_color; ?>" size="<?= $bar_font_size; ?>">Member Login</font></td> </tr> <tr> <td colspan="2"> <table border="0" cellpadding="0" cellspacing="0" width="100%"> <form action="/include/login.php" method=post name=loginform> <tr> <td valign="top"> <font face="<?= $text_font_face; ?>" color="<?= $text_font_color; ?>" size="<?= $text_font_size; ?>">You're logged in as: <?= $login; ?></font> <font face="<?= $text_font_face; ?>" color="<?= $text_font_color; ?>" size="<?= $text_font_size; ?>">Logoff </font><input type="image" src="/skin1/images/go_menu.gif" border="0" align="absmiddle" width="27" height="14"> </td> </tr> <input type="hidden" name="mode" value="logout"><input type="hidden" name="redirect" value="customer"> </form> </table> </table> <? } ?>
Reply With Quote
  #2  
Old 07-16-2004, 10:29 AM
  Jon's Avatar 
Jon Jon is offline
 

X-Guru
  
Join Date: Oct 2002
Location: Vancouver, Canada
Posts: 4,200
 

Default

The login/logout right now goes to the store after hitting submit. You could change this to have it login to itself, by changing the redirect variable in the code, and then editing your login.php to redirect based on that new variable.
Reply With Quote
  #3  
Old 07-16-2004, 02:11 PM
  adpboss's Avatar 
adpboss adpboss is offline
 

X-Man
  
Join Date: Feb 2003
Location: Ontario, Canada
Posts: 2,389
 

Default

Nice work.
Reply With Quote
  #4  
Old 09-30-2007, 11:07 AM
  proboscidian's Avatar 
proboscidian proboscidian is offline
 

Senior Member
  
Join Date: May 2005
Location: Clearwater, FL
Posts: 146
 

Default Re: A member login/logout auth box on non-xcart pages

I am getting the login/logout to work, but I get the following error:
Warning: Cannot modify header information - headers already sent by (output started at /home/pullman-holt/www/pullmanholtcorporation.com/cart/index.php:13) in /home/pullman-holt/www/pullmanholtcorporation.com/cart/include/sessions.php on line 72
Warning: Cannot modify header information - headers already sent by (output started at /home/pullman-holt/www/pullmanholtcorporation.com/cart/index.php:13) in /home/pullman-holt/www/pullmanholtcorporation.com/cart/include/sessions.php on line 74
Warning: Cannot modify header information - headers already sent by (output started at /home/pullman-holt/www/pullmanholtcorporation.com/cart/index.php:13) in /home/pullman-holt/www/pullmanholtcorporation.com/cart/include/sessions.php on line 83
Warning: Cannot modify header information - headers already sent by (output started at /home/pullman-holt/www/pullmanholtcorporation.com/cart/index.php:13) in /home/pullman-holt/www/pullmanholtcorporation.com/cart/include/sessions.php on line 84
Warning: Cannot modify header information - headers already sent by (output started at /home/pullman-holt/www/pullmanholtcorporation.com/cart/index.php:13) in /home/pullman-holt/www/pullmanholtcorporation.com/cart/include/sessions.php on line 91
Warning: Cannot modify header information - headers already sent by (output started at /home/pullman-holt/www/pullmanholtcorporation.com/cart/index.php:13) in /home/pullman-holt/www/pullmanholtcorporation.com/cart/include/sessions.php on line 237
Warning: Cannot modify header information - headers already sent by (output started at /home/pullman-holt/www/pullmanholtcorporation.com/cart/index.php:13) in /home/pullman-holt/www/pullmanholtcorporation.com/cart/include/sessions.php on line 105
Warning: Cannot modify header information - headers already sent by (output started at /home/pullman-holt/www/pullmanholtcorporation.com/cart/index.php:13) in /home/pullman-holt/www/pullmanholtcorporation.com/cart/include/sessions.php on line 106
Warning: Cannot modify header information - headers already sent by (output started at /home/pullman-holt/www/pullmanholtcorporation.com/cart/index.php:13) in /home/pullman-holt/www/pullmanholtcorporation.com/cart/include/get_language.php on line 155

Any ideas?
__________________
Industrial Webworks
Various xcart versions from 4.1.19 gold - 4.7 gold
http://www.industrialwebworks.net
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Dev Questions



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -8. The time now is 03:55 PM.

   

 
X-Cart forums © 2001-2020