Reputation: 3
I'm quite new to CodeIgniter. I've created this form, but clicking on either of the buttons doesn't run the controller method defined in echo form_open. Clicking on either submit button does nothing at all.
<?php echo form_open('home/login'); ?>
<label for="username">USERNAME</label>
<input type="text" size="30" name="username" value="<?php if (get_cookie('username')) { echo get_cookie('username'); } ?>" style="text-transform:uppercase;"/><br/>
<label for="email">EMAIL</label>
<input type="text" size="30" name="email" value="<?php if (get_cookie('email')) { echo get_cookie('email'); } ?>" style="text-transform:uppercase;"/><br/>
<label for="password">PASSWORD</label>
<input type="password" size="30" name="password" value="<?php if (get_cookie('password')) { echo get_cookie('password'); } ?>" style="text-transform:uppercase;"/><br/>
<input type="checkbox" id="cookiecheck" name="cookiecheck" value="Remember">
<label for="cookiecheck" <?php if (get_cookie('username')) { ?> checked="checked" <?php } ?>>REMEMBER_ME</label><br>
<input type="submit" name="submit" class="button" value="LOG_IN"/>
<input type="submit" name="submit" class="button" value="CREATE_ACCOUNT"/>
<?php echo form_close(); ?>
The login method I want to run is just:
<?php defined('BASEPATH') OR exit('No direct script access allowed');
class Home extends CI_Controller {
public function login(){
$this->load->view('dashboard');
}
My default_controller is already to set to 'home' by the way. If anyone could help it would be greatly appreciated, cheers.
Upvotes: 0
Views: 83
Reputation: 82
open your autoload file then load the html helper
application/config/autoload.php
$autoload['helper'] = array('url_helper','form', 'html', 'url');
Upvotes: 0
Reputation: 1501
Load the url
and form
helpers from the function where you load that view.
$this->load->helper(array("url", "form"));
And change the following
<?php echo form_open(base_url('home/login')); ?>
//make sure you set the base_url properly
If it didn't work , simple replace it with
<form action="<?=base_url('home/login');?>" method="post">
Upvotes: 0
Reputation: 523
Set the base_url in application/config/config.php.
$config["base_url"] = "http://localhost/project_folder/";
In your View change the form tag as shown bellow:
<?php echo form_open(base_url("home/login")) ?>
good luck
Upvotes: 0