如何在OSCommerce注册中创建链接,然后返回链接页面


how to create link in OSCommerce registration and then return to linked page?

我在导航栏中有一个链接,它将用户重定向到登录页面(见下面的代码)。登录注册完成后。我希望他们被转发到链接,但现在它把他们带回到主页。

        // if the customer is not logged on, redirect them to the login page 
    if (!tep_session_is_registered('customer_id')) { 
    // Not logged in 
    tep_redirect(tep_href_link(FILENAME_LOGIN, '', 'SSL')); 
}

我试图找到登录页面上的代码,但没有什么看起来熟悉的我。谢谢。

从外观上看,您使用的是OS Commerce,对吗?我对OS Commerce没有什么经验,但我对PHP有很多经验。以下是我将尝试的内容:

// if the customer is not logged on, redirect them to the login page 
if (!tep_session_is_registered('customer_id')) { 
    // Add session variable to redirect after login
    $_SESSION["redirect_after_login"] = "http://" . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URl'];
    // Not logged in
    tep_redirect(tep_href_link(FILENAME_LOGIN, '', 'SSL')); 
}

然后在你的登录执行中,你可以这样写:

// Redirect if needed
if ( !empty($_SESSION["redirect_after_login"]) ) {
    header( 'Location: ' . $_SESSION["redirect_after_login"] );
}

当然,根据OS Commerce的工作方式,你可能需要添加一些代码来避免无限循环,或者加强重定向的安全性…但这应该会让你接近你需要的。

相关文章: