[eluser]alvaroeesti[/eluser]
UPDATE: problem solved completely thanks to 'InsiteFX'. Thank you
============
Hello
I am trying to do a very simple thing. One page with a Form to enter username and pwd. It should be inserted in the DB.
Here is the CONTROLLER
Code:
<?php
class Inserting_controller extends CI_Controller {
public function __construct()
{
parent::__construct();
$this->load->model('inserting_model');
}
public function index ()
{
$this->load->view('inserting_view');
}
public function insert()
{
extract($_POST); # this hopefully should get the posted data on the form ..
$this->Inserting_model->insertdata($username, $password);#this should forward them to the Model
}
}
?>
Here is the MODEL
Code:
<?php
class Inserting_model extends CI_Model{
function __construct()
{
// Call the Model constructor
parent::__construct();
$this->load->database();
}
public function insertdata($username, $password)
{
$hashed_pwd = sha1($password);
$data = array(
'username' => 'Username',
'password' => '$hashed_pwd'
);
$this->db->insert('users', $data);
}
}
?>
And here is the View. But nothing gets inserted. The field for the Pwd has been set to Binary 20 (UNHEX function)
Code:
<?php echo form_open(base_url() . 'index.php/inserting_controller/inserting_view'); ?>
<ul>
<li>
<label>Username</label>
<div><?php echo form_input(array('id' => 'username', 'name' => 'username')); ?></div>
</li>
<li>
<label>Password</label>
<div><?php echo form_password(array('id' => 'password', 'name' => 'password')); ?></div>
</li>
<li><?php echo validation_errors();?></li>
<li><?php echo form_submit(array('name' =>'submit'),'Insert');?> </li>
</ul>
<?php echo form_close(); ?>