CodeIgniter_Learner CodeIgniter_Learner - 7 months ago 34
PHP Question

IP address is showing in form action with CodeIgniter http://::1/codeigniter/ in html sourcecode

I have the CI script installed on Xampp. Currently I am working on forms and when I click on submit on html, it does nothing.

I tried

echo form_open('verifylogin');
echo form_open();


It show on sourcecode as

<form action="http://::1/codeigniter/verifylogin">
<form action="http://::1/codeigniter/">


respectively.

I don't understand what this
"http://::1/"
is and how to get rid of it?

Answer

When your url in form action shows

  • http://::1/yourproject/
  • http://127.0.0.1/yourproject/

Chances are you have left the base url blank

$config['base_url'] = '';

Now days in latest versions of codeIgniter it is not recommend that you leave your base_url blank.

  • $config['base_url'] = 'http://localhost/yourproject/';
  • $config['base_url'] = 'http://www.example.com/';

And is always good to end url with /

You may need to create routes for your form here

application > config > routes.php

CodeIgniter 3: Routing

CodeIgniter 2: Routing


Update:

With CodeIgniter 3 + versions:

When you create a file remember you will have to have first letter ONLY upper case on file names and classes.

What will happen sometimes is that it all may well work in a localhost environment with lower case but when you go to a live server some times will throw errors or not submit forms correct etc.

Example: From Controllers This also applies to Models

This is valid

File name: Verifylogin.php

<?php

class Verifylogin extends CI_Controller {

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

    public function index() {

    }

}

This is valid

File name: Verify_login.php

<?php

class Verify_login extends CI_Controller {

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

    public function index() {

    }

}

This is not valid

File name: verifylogin.php

class verifylogin extends CI_Controller {

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

    public function index() {

    }

}

This is not valid

File name: Verify_Login.php

class Verify_Login extends CI_Controller {

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

    public function index() {

    }

}

Codeigniter Doc's

Comments