2

我有一个 CMS,我正在 CMS 文件夹之外开发一个移动站点。我已包含 CMS 文件以使用 CMS 中的所有功能。

<?php include_once'/home/flyeurov/public_html/core/codon.config.php';?>

在移动网站上,我有一个登录表单。使用包含文件中的函数将信息提交回 CMS。

<form name="loginform" action="<?php echo url('/login');?>" method="post">

提交时,这会将其带到 site_url/index.php/login。在表单的提交按钮上方,我隐藏了一个重定向输入,但我希望能够返回目录,以便找到 /mobile 目录。

<input type="hidden" name="redir" value="../mobile/crew_center.php" />
<input type="hidden" name="action" value="login" />
<input class="login-btn" type="submit" name="submit" value="Log In" />

这应该将它重定向到 m.site_url/crew_center.php ('m' 是 /mobile 目录的路径),但它会像这样重定向它,并且拒绝返回:

site_url/index.php/mobile/crew_center.php

我怎样才能让它正确重定向?我希望我没有让任何人感到困惑。

4

1 回答 1

2

在 CMS 文件中,将其替换为:

$this->post->redir = str_replace('index.php/', '', $this->post->redir);
header('Location: '.url('/'.$this->post->redir));

有了这个:

if (isset($_POST['mobileVersion'])) {
    header('Location: ' . $_SERVER['DOCUMENT_ROOT'] . '/crew_center.php');
} else {
    $this->post->redir = str_replace('index.php/', '', $this->post->redir);
    header('Location: '.url('/'.$this->post->redir));
}

在登录表单的 HTML 中添加另一个隐藏的输入

<input type="hidden" name="mobileVersion" value="True">

这是我能想到的唯一方法。

于 2013-07-25T18:45:38.777 回答