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

Login Form Modification

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions
 
Thread Tools Search this Thread
  #11  
Old 11-12-2003, 11:18 PM
  BoomBoomBap's Avatar 
BoomBoomBap BoomBoomBap is offline
 

Senior Member
  
Join Date: Nov 2002
Location: San Francisco
Posts: 184
 

Default

Seems like a pretty cool mod but regardless of which incarnation of it I use it only gets redirected to a blank page. The page source is cart.php?mode=auth but it is blank.

Im using Netscape 7.1 and Xcart 3.4.9
__________________
Site 1 > XCART LIVE 3.4.12

Site 2 > XCART LIVE 4.0.17
Reply With Quote
  #12  
Old 11-18-2003, 04:36 AM
  carlisleglass's Avatar 
carlisleglass carlisleglass is offline
 

eXpert
  
Join Date: Aug 2003
Location: Carlisle, UK
Posts: 316
 

Default

looks like you missed a } on the end of that coding ...

This is the revised coding ...
Quote:
Code:
if ($login_type=="C") { if(!func_is_cart_empty($cart)) func_header_location("../$redirect/cart.php"); else { $relo_page = strrchr($_SERVER['HTTP_REFERER'], '/'); $relo_page = str_replace('/', '', $relo_page); func_header_location("../$redirect/$relo_page"); } }

Tried it in 3.4.9 and works.
__________________
Darren Kierman
Carlisle Glass (http://www.carlisleglass.co.uk/)
... running X-Cart Gold 4.4.5 [unix]
Reply With Quote
  #13  
Old 11-28-2003, 04:08 PM
  BoomBoomBap's Avatar 
BoomBoomBap BoomBoomBap is offline
 

Senior Member
  
Join Date: Nov 2002
Location: San Francisco
Posts: 184
 

Default

Looks like I got this working with Hair Guy's code.
Here's what Im using for 3.4.10

Code:
# new login mod $mysite_pattern = '~^(http://'.$xcart_http_host.'|https://'.$xcart_https_host.')~'; if($login_type=="C" && !func_is_cart_empty($cart)) { if (preg_match('/\/cart\.php\?mode=(auth|checkout)/', $_SERVER['HTTP_REFERER'])) { # go to next step in checkout func_header_location("../$redirect/cart.php?mode=checkout"); } elseif (preg_match($mysite_pattern, $_SERVER['HTTP_REFERER'])) { # go back to where we were before login func_header_location(" ".$_SERVER['HTTP_REFERER']); } else { func_header_location("../$redirect/cart.php"); } } elseif ( ($config["General"]["default_pwd"]=="Y") and (count($default_accounts)>0) and $admin_safe_mode==false) { echo"<SCRIPT language='JavaScript'> alert('Default passwords for one or more administrator/provider accounts are not changed. We recommend you to change default passwords for security reasons. The default X-cart accounts$default_accounts_string!'); self.location='$to_url'; </SCRIPT>If you see this message it means that your browser doesn't support Javascript or it is disabled. Please enable JavaScript in your browser settings for proper X-Cart functionality."; x_session_save(); exit; } else { if (preg_match($mysite_pattern, $_SERVER['HTTP_REFERER'])) { # go back to where we were before login func_header_location(" ".$_SERVER['HTTP_REFERER']); } else { func_header_location("../$redirect/home.php"); } } } # here ends new login mod
__________________
Site 1 > XCART LIVE 3.4.12

Site 2 > XCART LIVE 4.0.17
Reply With Quote
  #14  
Old 01-24-2004, 10:01 AM
 
PhilJ PhilJ is offline
 

X-Guru
  
Join Date: Nov 2002
Posts: 4,094
 

Default

Great Mod, ought to be standard in X-Cart, but has anyone updated this for v3.5.x ?

PhilJ
Reply With Quote
  #15  
Old 05-09-2004, 06:30 PM
 
xcell67 xcell67 is offline
 

Senior Member
  
Join Date: Dec 2003
Posts: 149
 

Default

Quote:
+++++++++++++++++++++++++++++++++++++++++++++
This modification will take you back to the page you came from unless you have something in your cart. In the latter case, it will take you to your shopping cart.
+++++++++++++++++++++++++++++++++++++++++++++
Original File: login.php
Code:
if ($login_type=="C") {
if(!func_is_cart_empty($cart))
header("Location: ../$redirect/cart.php");
else
header("Location: ../$redirect/home.php");
exit;
}

Modified File: login.php
Code:
if ($login_type=="C") {
if(!func_is_cart_empty($cart))
header("Location: ../$redirect/cart.php");
else {
$relo_page = strrchr($_SERVER['HTTP_REFERER'], '/');
$relo_page = str_replace('/', '', $relo_page);
header("Location: ../$redirect/$relo_page");
}
exit;
}



There is a slight problem with this.
Example:

The customer tries logging in either through the side panel login box or the center login box but enters a wrong password or wrong username. The incorrect password/username message will show up, and then they enter the correct details and log in. The problem is that the incorrect password/username message will still show, and it might confuse some customers who will wonder why that message is still there if they just logged in correctly.

How would you apply an exception to the code so that if the customer is logging in after an unsuccesful attempt, that it would either redirect them back to page they were at before or back to the home page.
Reply With Quote
  #16  
Old 05-10-2004, 02:05 AM
 
jeremye jeremye is offline
 

Senior Member
  
Join Date: Apr 2004
Location: Philadelphia, PA
Posts: 158
 

Default

I ran into the same issue, and I just added an exception for the page "error_message.php?login_incorrect", as follows (this is my entire code snippet:

Code:
if ($login_type=="C") { /* If the cart has items in it, redirect them to their cart */ if(!func_is_cart_empty($cart)) { func_header_location("../$redirect/cart.php"); } /* Otherwise, find what page they were at and send them there */ else { $relo_page = strrchr($_SERVER['HTTP_REFERER'], '/'); $relo_page = str_replace('/', '', $relo_page); /* Unless they were on the "Login" individual page */ if ($relo_page == "error_message.php?login_incorrect") $relo_page = "home.php"; func_header_location("../$redirect/$relo_page"); } }

Hope this helps.
__________________
Jeremy
X-Cart Gold v3.4.14 [Linux/Apache]
Heavily Modded
Reply With Quote
  #17  
Old 05-23-2004, 11:23 PM
 
xcell67 xcell67 is offline
 

Senior Member
  
Join Date: Dec 2003
Posts: 149
 

Default Hi, question about your login form solution

Hi,
Thank you for your modification, I was able to integrate it succesfully:

"I ran into the same issue, and I just added an exception for the page "error_message.php?login_incorrect", as follows (this is my entire code snippet: "

Code:
if ($login_type=="C") { /* If the cart has items in it, redirect them to their cart */ if(!func_is_cart_empty($cart)) { func_header_location("../$redirect/cart.php"); } /* Otherwise, find what page they were at and send them there */ else { $relo_page = strrchr($_SERVER['HTTP_REFERER'], '/'); $relo_page = str_replace('/', '', $relo_page); /* Unless they were on the "Login" individual page */ if ($relo_page == "error_message.php?login_incorrect") $relo_page = "home.php"; func_header_location("../$redirect/$relo_page"); } }


What I have been having trouble with is integrating the checkout bit that was also in the same post. Were you able to get the correct code so that the customer would be redirected to step 2 if they signed in the middle of the checkout process?

By the way,

this bit for the above code also redirects them to home if they mistype their login/pw 3 times and are given the recover password screen:

if ($relo_page == "error_message.php?login_incorrect" OR "help.php?section=Password_Recovery")

Thanks,
James
Reply With Quote
  #18  
Old 05-26-2004, 02:24 AM
 
arabayaservis.com arabayaservis.com is offline
 

Member
  
Join Date: Nov 2003
Posts: 10
 

Default

for 3.5.7

if customer directory different name
codes must be :

Code:
if ($login_type=="C") { if(!func_is_cart_empty($cart)) { func_header_location("$redirect_to/cart.php"); }else { $relo_page = strrchr($_SERVER['HTTP_REFERER'], '/'); $relo_page = str_replace('/', '', $relo_page); if ($relo_page == "error_message.php?login_incorrect") $relo_page = "home.php"; func_header_location("$redirect_to/$relo_page"); } }
Reply With Quote
  #19  
Old 05-29-2004, 06:30 AM
 
laureon laureon is offline
 

Senior Member
  
Join Date: Oct 2003
Posts: 171
 

Default

Hi,

I have recently begun a fresh install of v3.5.8. I don't know if it's just me, but when I modify login.php to redirect to the referring page, the cart still redirects to either home.php or the cart. I have deleted all cached templates etc. but am still having no luck. Is anyone else experiencing a similar problem?

P.S - I have had the code working successfully in v3.5.7

thanks
__________________
X-Cart Gold Version: 4.0.17
X-Configurator
X-AOM
X-FancyCategories
X-RMA
X-Offers
Reply With Quote
  #20  
Old 06-04-2004, 11:59 PM
 
xcell67 xcell67 is offline
 

Senior Member
  
Join Date: Dec 2003
Posts: 149
 

Default

what would be the correct code if you had moved the contents from /customer into the root of your site? I did this so the site could be accessed by shop.com/home.php instead of shop.com/customer/home.php

I'm currently using this code:
Code:
if ($login_type=="C") { if(!func_is_cart_empty($cart)) { func_header_location("$redirect_to/cart.php"); }else { $relo_page = strrchr($_SERVER['HTTP_REFERER'], '/'); $relo_page = str_replace('/', '', $relo_page); if ($relo_page == "error_message.php?login_incorrect") $relo_page = "home.php"; func_header_location("$redirect_to/$relo_page"); } }

The redirect for the cart.php works but the redirect for the relopage does not. It redirects to my index.html rather than home.php.
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 11:37 AM.

   

 
X-Cart forums © 2001-2020