Welcome Guest, Not a member yet? Register   Sign In
Routing problem on Live server
#1

My codeIgniter application only shows default controller on live server but runs just fine on local server, the default controller has a view method which displays login page as the first page but submit button wont submit upon providing login details my index.php page is set to production environment below are my config and route files . please help



// Config.php 

$config['base_url'] = 'http://phpstack-114475326109.cloudwaysapps.com/';

$config['index_page'] = 'index.php?';


$config['uri_protocol']    = 'REQUEST_URI';

//end config.php


//routes.php


$route['(:any)'] = 'pages/view/$1';
$route['default_controller'] = 'pages/view';

$route['404_override'] = '';
$route['translate_uri_dashes'] = FALSE;
//end config
Reply
#2

Read the Users Guide

The default controller

You can NOT use a directory as a part of this setting!
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#3

(09-13-2017, 08:24 AM)InsiteFX Wrote: Read the Users Guide

The default controller

You can NOT use a directory as a part of this setting!

I have looked at the User Guide , still i dont understand what you mean I can not use a directory as part of the setting
Reply
#4

You can not use a directory in the default controller:

PHP Code:
$route['default_controller'] = 'pages/view'

Your view is in a directory called pages.


I can not send you any messages because you have Private messages disabled!
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#5

(09-14-2017, 08:40 AM)InsiteFX Wrote: You can not use a directory in the default controller:

PHP Code:
$route['default_controller'] = 'pages/view'

Your view is in a directory called pages.


I can not send you any messages because you have Private messages disabled!

Hi Insite i just enabled my Private message please do reply .



I have  a controller page called Pages.php with a class called Pages and a method view

Thats why I though the routing for the default controller should then be

$route['default_controller'] = 'pages/view';


class Pages extends MY_Controller
{

if (!file_exists(APPPATH.'views/'.$page.'.php'))
        {
            // Whoops, we don't have a page for that!
           
            show_404();
        }

    public function view($page = 'login')
    {

// rest of code
}
}
Reply
#6

(This post was last modified: 09-15-2017, 11:28 AM by ciadvantage.)

Code:
<?

class Pages extends My_Controller{
  //...may need __constructor()
  function view(){
     $this->load->view('yourview');
  }//end view()
} //end class

//Assume yourview.php is under application/views/yourview.php
// then your route is like this in routes.php
...
$route['default_controller']='pages/view'
Then it should show on your default landing site with content of yourview.php
Reply
#7

(09-15-2017, 11:26 AM)ciadvantage Wrote:
Code:
<?

class Pages extends My_Controller{
  //...may need __constructor()
  function view(){
     $this->load->view('yourview');
  }//end view()
} //end class

//Assume yourview.php is under application/views/yourview.php
// then your route is like this in routes.php
...
$route['default_controller']='pages/view'
Then it should show on your default landing site with content of yourview.php

Thank you for the input, i tried to add the constructor like you said, check below, but still though the login in page is displayed as the fist page but submit button wont submit upon giving my login in details

class Pages extends MY_Controller
{

public function __construct()
    {
        parent::__construct();

$this->load->library('session');

              
    }
    public function index($page = 'login')
    {
        if (!file_exists(APPPATH.'views/'.$page.'.php'))
        {
            // Whoops, we don't have a page for that!
           
            show_404();
        }

        $data['title'] = ucfirst($page); // Capitalize the first letter

f($page == 'dashboard') {
            $this->load->model('model_student');
            $this->load->model('model_teacher');
            $this->load->model('model_classes');
            $this->load->model('model_marksheet');
          

            $data['countTotalStudent'] = $this->model_student->countTotalStudent();
            $data['countTotalTeacher'] = $this->model_teacher->countTotalTeacher();
            $data['countTotalClasses'] = $this->model_classes->countTotalClass();
            $data['countTotalMarksheet'] = $this->model_marksheet->countTotalMarksheet();
}

 if($page == 'login') {
           if($this->session->userdata('logged_in') === true) {
            redirect('../dashboard');
        }
            $this->load->view($page, $data);
        }
}
}
Code:
...
$route['default_controller']='pages'
 and i have a view page called login.php in the application/views folder  which is displayed fine but it wont submit and redirect to the next page which is the dashboard.php which is also present in the  application/views folder but it routes and redirects just fine on my local server
Reply




Theme © iAndrew 2016 - Forum software by © MyBB