X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Dev Questions (https://forum.x-cart.com/forumdisplay.php?f=20)
-   -   A member login/logout auth box on non-xcart pages (https://forum.x-cart.com/showthread.php?t=8493)

Jon 07-16-2004 10:25 AM

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>

<?
}
?>


Jon 07-16-2004 10:29 AM

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.

adpboss 07-16-2004 02:11 PM

Nice work.

proboscidian 09-30-2007 11:07 AM

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?


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

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.