Im using Codeigniter to create a login system. Im new to CI. How can I block the direct access to signup. I want to make sure anonymous have to accept the terms before go up to signup view.
view controller
<?php $attr_form = array('class' => 'form-horizontal');
echo form_open('login/accept', $attr_form); ?>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<div class="checkbox">
<label>
<?php echo form_checkbox('terms', 'accept', FALSE); ?>
</label>
</div>
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-4 col-sm-8">
<?php
$data_submit = array('class'=> 'btn btn-info', 'name' => 'submit', 'value'=> 'Accept');
echo form_submit($data_submit);?>
</div>
</div>
controller
function accept ()
{
$this->load->library('form_validation');
$this->form_validation->set_rules('terms', 'required');
if($this->form_validation->run() == TRUE)
{
if ($this->input->post('terms'))
{
redirect('login/signup');
}
else
{
$this->terms();
}
}
}
should I use session library to do the job? or any other simpler methods?
thanks
You can use session variable . But you can write the code in user defined controller extending CI_Controller. And then use this user defined controller to declare other controllers. I would save you from writing signup code individually for every controller.