[eluser]ywftdg[/eluser]
Ok, like I said, I am still new, i'm missing some logic in all this. I have been trying to tweak from the lesson in the user guide, but the part with checking the database is doing nothing. I think the values are not being sent to my query or something. I will later move my query to the models, but for right now just have it in the controller. Can anyone lend some advice on what is wrong with this?
Code:
class Form extends Controller {
/////////////////////////////
function index() {
$this->load->helper(array('form', 'url'));
$this->load->library('validation');
//Set rules for forms
$rules['email'] = "trim|required|valid_email";
$rules['password'] = "required";
$this->validation->set_rules($rules);
//Reset form keeps email entered.
$fields['email'] = 'Email';
$fields['password'] = 'Password';
$this->validation->set_fields($fields);
//check the status
if ($this->validation->run() == TRUE) {
$this->db->select('*');
$this->db->where('designer.dEmail' , '$email');
$this->db->where('designer.dPassword' , '$password');
$this->db->from('designer');
$query = $this->db->get();
if ($query->num_rows() > 0) {
$this->load->view('formsuccess');
} else {
$this->load->view('myform');
}
}
else {
$this->load->view('myform');
}
}
/////////////////////////////
}
myform.php (view)
Code:
<? $attributes = array('class' => 'accountForm', 'id' => 'form') ?>
<?=$this->validation->set_error_delimiters('<div><strong>', '</strong></div>')?>
<?=$this->validation->error_string?>
<?=form_open (base_url().'form', $attributes) ?>
<?=form_hidden ('go', 'true')?>
<div class="accountEntryA">
<div class="accountLeft">Email</div>
<div class="accountRight"><?=form_input('email', $this->validation->email)?></div>
<div class="clear"></div>
<div class="accountLeft">Password</div>
<div class="accountRight"><?=form_password('password')?></div>
<div class="clear"></div>
</div>
<div class="accountEntry">
<div class="accountLeft"><?=form_submit('submit', 'Submit')?></div>
<div class="accountRight"></div>
<div class="clear"></div>
</div>
<?=form_close()?>