IP address is showing in form action with CodeIgniter http://::1/codeigniter/ in html sourcecode
If ip address is displayed in form action or url
http://::1/yourproject/
http://127.0.0.1/yourproject/
Chances are you have left the base url blank
/*
|--------------------------------------------------------------------------
| Base Site URL
|--------------------------------------------------------------------------
|
| URL to your CodeIgniter root. Typically this will be your base URL,
| WITH a trailing slash:
|
| http://example.com/
|
| WARNING: You MUST set this value!
|
| If it is not set, then CodeIgniter will try guess the protocol and path
| your installation, but due to security concerns the hostname will be set
| to $_SERVER['SERVER_ADDR'] if available, or localhost otherwise.
| The auto-detection mechanism exists only for convenience during
| development and MUST NOT be used in production!
|
| If you need to allow multiple domains, remember that this file is still
| a PHP script and you can easily do that on your own.
|
*/
$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
why i'm having this [::1] in my URL using Codeigniter
You're using IPv6 and most-likely don't have $config['base_url']
set in your config.php file.
Refer to this documentation for more information.
codeigniter page not found
if your home controler name start with H("Home.php"), rename to home.php.
Codeigniter object not found error
Your login method should in Login_model
return :
return $data->row();
not :
return $data = row();
Edit
You need to pass the user info to your mode:
this two line should be in your controller:
public function user(){
$usuario=$this->input->post('usuario', TRUE);
$contrasena=md5($this->input->post('contrasena', TRUE));
$data['login']=$this->Login_model->login($usuario, $contrasena);
$this->load->view('user', $data);
}
and your model :
public function login($usuario, $contrasena) {
$this->db->where('usuario',$usuario);
$this->db->where('contrasena',$contrasena);
$query = $this->db->get("your_table_name");
return $query->row_array();
}
How to set proper codeigniter base url?
Base URL should be absolute, including the protocol:
$config['base_url'] = "http://somesite.com/somedir/";
If using the URL helper, then base_url()
will output the above string.
Passing arguments to base_url()
or site_url()
will result in the following (assuming $config['index_page'] = "index.php";
:
echo base_url('assets/stylesheet.css'); // http://somesite.com/somedir/assets/stylesheet.css
echo site_url('mycontroller/mymethod'); // http://somesite.com/somedir/index.php/mycontroller/mymethod
Related Topics
Pdo SQL-State "00000" But Still Error
Php: What Is the Purpose of Session_Name
Php: Equivalent of Include Using Eval
How to Detect If a User Uploaded a File Larger Than Post_Max_Size
Php: How to Add Leading Zeros/Zero Padding to Float via Sprintf()
PHP - Is "Include" Function Secure
Including PHP Variables in an External Js File
Setting $_Session Doesn't Work on Localhost Using Xampp
How to Display a PHP Variable into HTML
PHP Static Method Call with Variable Class Name and Namespaces
Does the Use Keyword in PHP Closures Pass by Reference
Set Multiple='False' in a Form in a Many to Many Relation Symfony2
Strip_Tags() Function Blacklist Rather Than Whitelist
Laravel 5.3 - HTMLspecialchars() Expects Parameter 1 to Be String
How to Set PHP's Auto_Prepend_File Directive Per Directory
PHP - Make Multi-Dimensional Associative Array from a Delimited String