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

Login From a page Outside of Xcart directory

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions
 
Thread Tools Search this Thread
  #1  
Old 02-20-2006, 06:41 PM
 
quickcel quickcel is offline
 

Newbie
  
Join Date: Jun 2005
Posts: 9
 

Default Login From a page Outside of Xcart directory

I had the need to login to the xcart store from an .htm page that was outside my xcart main directory. I couldn't find a post with the info so I thought I'd share it. With a few simple lines I was easily able to login from an html page. Here is the code:

First, open up include/login.php

Find:
Code:
if ($REQUEST_METHOD == "POST") {

Add Just Before that line:
Code:
$outSideLogin = $_POST['outsideLogin']; if ($outSideLogin == 'outsideLogin') { $mode = "login"; $usertype = "C"; }


Next, Find:
Code:
$username = $HTTP_POST_VARS["username"]; $password = $HTTP_POST_VARS["password"];

And Replace With:
Code:
//insert an if else that switches between default xcart login and outside variables POSTed from outside xcart if ($outSideLogin == 'outsideLogin') { $username = $_POST['username']; $password = $_POST['password']; } else { $username = $HTTP_POST_VARS["username"]; $password = $HTTP_POST_VARS["password"]; }


Now - You'll need to open up the HTML page you want to login from and add make sure that your User Name input box has the name of "username" and the password box has the name of "password".

You'll also need to add a hidden input box with the name of "outsideLogin"

Here's a sample from my HTML:
Code:
<input name="password" type="password" id="password" size="13"> <input name="imageField" type="image" src="images/go_button.gif" align="top" width="20" height="18" border="0"> <input name="outsideLogin" value="outsideLogin" type="hidden">

The last thing you'll need to do is make sure the action on your form has the following path: [xcart path]/include/login.php

Hopefully - that can help someone else!
__________________
4.1.6 - gold
Unix
Reply With Quote
  #2  
Old 02-28-2006, 12:22 AM
 
davide davide is offline
 

Member
  
Join Date: Jan 2006
Posts: 15
 

Default

Thanks for your post!

Are you using it to avoid anonymous visitors?

I would like to use x-cart a a website only accesible for my registered clients (sort of a extranet inside my public websitepage).

Does somebody know how to forbid entry to non-registered visitors?

EDITED:
I found this topic that may help other users with the same problem
http://forum.x-cart.com/viewtopic.php?t=14069

Regards,
David
__________________
David Estapц╘

X-cart version \"x-cart-4[1].0.17gold\"
Reply With Quote
  #3  
Old 03-12-2006, 07:41 AM
  ShishaPipeUK's Avatar 
ShishaPipeUK ShishaPipeUK is offline
 

Senior Member
  
Join Date: Jul 2005
Location: London, England.
Posts: 118
 

Default

Thanks for the code, i have completed the extra code you missed out for the username on the html page and also a link to register a new account and recover the password link. Just replace the www.shisha.co.uk/shopcart/ with your own web site address.

Code:
<table width="73%" border="0"> <tr> <td width="60%"> <FORM action="https://www.shisha.co.uk/shopcart/include/login.php" method="post" name="authform"> Username<input name="username" type="username" id="username" size="16"> Password<input name="password" type="password" id="password" size="16">Log In <input name="imageField" type="image" src="https://www.shisha.co.uk/shopcart/skin1/images/custom/but_head2.gif" align="top" width="20" height="18" border="0"> <input name="outsideLogin" value="outsideLogin" type="hidden"></FORM></td> <td width="35%">Register New account Recover Password</td></tr></table>
__________________
Apache/2.0.55 (Red Hat) & MYSQL Server: 5.0.24
PERL: 5.008005 / PHP: 4.4.4 - 4.3.1 X-CART

Shop carts at
http://www.nightscene.co.uk/shop/home.php
http://www.theshisha.net/shopcart/home.php
http://www.system-maintenance.com/maint/home.php
http://www.tabac4u.com
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Dev Questions


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 12:10 PM.

   

 
X-Cart forums © 2001-2020