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)
-   -   Login Form Modification (https://forum.x-cart.com/showthread.php?t=2404)

BoomBoomBap 11-12-2003 11:18 PM

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

carlisleglass 11-18-2003 04:36 AM

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.

BoomBoomBap 11-28-2003 04:08 PM

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


PhilJ 01-24-2004 10:01 AM

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

PhilJ

xcell67 05-09-2004 06:30 PM

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.

jeremye 05-10-2004 02:05 AM

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.

xcell67 05-23-2004 11:23 PM

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

arabayaservis.com 05-26-2004 02:24 AM

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");
                        }
                }


laureon 05-29-2004 06:30 AM

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

xcell67 06-04-2004 11:59 PM

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.


All times are GMT -8. The time now is 08:00 AM.

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