Reputation: 101
I have a CMS, and I'm developing a mobile site outside the CMS folders. I have included the CMS file to use all of the functions from the CMS.
<?php include_once'/home/flyeurov/public_html/core/codon.config.php';?>
On the mobile site, I have a login form. The information submits back to the CMS using the functions from the included file.
<form name="loginform" action="<?php echo url('/login');?>" method="post">
On submit, this will take it to site_url/index.php/login. Just above the Submit button for the form, I've hidden a redirect input but I want to be able to go back in terms of directories, in order to find /mobile directory.
<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" />
This should redirect it to m.site_url/crew_center.php ('m' is the path for /mobile directory) but it's instead redirecting it like this, and refuses to go back:
site_url/index.php/mobile/crew_center.php
How can I get it to redirect properly? I'm hoping I haven't confused anyone.
Upvotes: 2
Views: 435
Reputation: 12341
In the CMS file, replace this:
$this->post->redir = str_replace('index.php/', '', $this->post->redir);
header('Location: '.url('/'.$this->post->redir));
With this:
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));
}
And in the HTML of the login form add another hidden input:
<input type="hidden" name="mobileVersion" value="True">
That's the only way to do this that I can think of.
Upvotes: 2