雖然有一些解決方案,我無法讓他們作爲我的情況的解決方案。登錄後重定向上一頁
我需要在用戶登錄後將用戶重定向到同一頁面而不是myaccount頁面。
從login.php;
if (isset($_POST['action']) && $_POST['action'] == "login")
{
$username = mysql_real_escape_string(getPostParameter('username'));
$pwd = mysql_real_escape_string(getPostParameter('password'));
$ip = getenv("REMOTE_ADDR");
if (!($username && $pwd))
{
$errormsg = "Please enter username and password";
}
else
{
$sql = "SELECT * FROM prcb_users WHERE username='$username' AND password='".PasswordEncryption($pwd)."' LIMIT 1";
$result = smart_mysql_query($sql);
if (mysql_num_rows($result) != 0)
{
$row = mysql_fetch_array($result);
if ($row['status'] == 'inactive')
{
header("Location: /login?msg=2");
exit();
}
smart_mysql_query("UPDATE prcb_users SET last_ip='$ip', login_count=login_count+1, last_login=NOW() WHERE user_id='".(int)$row['user_id']."' LIMIT 1");
if (!session_id()) session_start();
$_SESSION['userid'] = $row['user_id'];
$_SESSION['FirstName'] = $row['fname'];
if ($_SESSION['goRetailerID'])
{
$redirect_url = RetailerSEOurl($_SESSION['goRetailerID']);
unset($_SESSION['goRetailerID']);
}
else
{
$redirect_url = "/myacount";
}
header("Location: ".$redirect_url);
exit();
}
else
{
header("Location: /login?msg=1");
exit();
}
}
}
登錄表單;
<form action="" method="post">
E-mail <input type="text" class="input2" name="username" value="<?php echo getPostParameter('username'); ?>" />
Password <input type="password" class="input2" name="password" value="" />
<input type="hidden" name="action" value="login" />
<input type="submit" class="butt" name="login" id="login" value="Login" />
</form>
我很感激,如果有人能幫助我,我該如何解決這個問題。