Welcome Guest, Not a member yet? Register   Sign In
Simple registration form problem
#1

[eluser]Unknown[/eluser]
Hi guys,

I am working on a quite large project, so I decide to use some framework. After a quick search I found CodeIgniter so I choose it. But after a few days the first problems came. One of it is that my POST variables are missing. Using simple controller for registration

Code:
<?php
class Registration extends CI_Controller
{
    public function __construct()
{
  parent::__construct();
  $this->load->database();
  $this->load->helper(array('form', 'url'));
  $this->load->library('form_validation');
}

    public function index()
    {
        $this->load->model('model');
  $this->load->model('layout');
  $this->register();
    }

public function register()
{
  $data['type'] = 'registration';
  
  $this->form_validation->set_rules('addlogin', 'Login',
            'trim|alpha_numeric|required|min_length[4]|max_length[25]|xss_clean');
  $this->form_validation->set_rules('addheslo', 'Password',
            'trim|alpha_numeric|required|min_length[5]|max_length[199]|matches[addheslo2]|md5|xss_clean');
  $this->form_validation->set_rules('addheslo2', 'Password confirmation',
            'trim|alpha_numeric|required|min_length[5]|max_length[199]|xss_clean');
  $this->form_validation->set_rules('addemail', 'Email',
            'trim|required|min_length[4]|max_length[249]|valid_email|xss_clean');
  
  if ($this->form_validation->run() == FALSE)
  {
   $this->load->view('registration',$data);
  }
  else
  {
   $this->load->view('test');
  }
  
}
}
?>

And a simple view

Code:
<?php $this->load->view('header'); ?>
<?php $this->load->view('left_sidebar.php'); ?>

<div class="td_m">
<div class="item"><div class="item_text"><span>&lt;?php $this->layout->get_page_content($type,$return_name = TRUE); ?&gt;</div></div><table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><td align="left"><div class="componentheading">&nbsp;</div>
<div class="componentheading">
&lt;?php echo validation_errors(); ?&gt;
&lt;?php
echo form_open("page?page=registration");

$username = array(
    'name' => 'addlogin',
    'style' => 'border: 1px solid #C7C7C7; background-color: #DFDFDF',
    'size' => '30',
    'value' => set_value('addlogin')
    );
$password = array(
    'name' => 'addheslo',
    'type' => 'password',
    'style' => 'border: 1px solid #C7C7C7; background-color: #DFDFDF',
    'size' => '30',
    'value' => ''
    );
$password2 = array(
    'name' => 'addheslo2',
    'type' => 'password',
    'style' => 'border: 1px solid #C7C7C7; background-color: #DFDFDF',
    'size' => '30',
    'value' => ''
    );
$email = array(
    'name' => 'addemail',
    'style' => 'border: 1px solid #C7C7C7; background-color: #DFDFDF',
    'size' => '30',
    'value' => set_value('addemail')
    );
$submit = array(
    'name' => 'submit',
    'value' => 'Send'
    );



?&gt;
<tr>
<td width="120" valign="top" align="right">&nbsp;
</td>
<td valign="top" align="right">&nbsp;
</td>
</tr>
<tr>
<td align="right">
<label for="addlogin" title="Login">Login:</label></td>
<td align="left">
  &lt;?php echo form_input($username); ?&gt;</td>
  <td width="200" align="left">
  (Minimum 4 and maximimum 25 characters)</td>
</tr>
<tr>
  <td align="right">
  <label for="addheslo" title="Password">Password:</label></td>
  <td align="left">
  &lt;?php echo form_password($password); ?&gt;
  <td width="200" align="left"> (You password must be equal to or longer than 5 characters.) </td>

</td>
</tr>
<tr>
  <td align="right">
  <label for="addheslo2" title="Confirm password">Password again:</label></td>
  <td align="left">
  &lt;?php echo form_password($password2); ?&gt;</td>
</tr>
<tr>
  <td align="right">
  <label for="addemail" title="E-mail">E-mail:</label></td>
  <td align="left">
  &lt;?php echo form_input($email); ?&gt;</td>
</tr>
<tr><td align="right">
&lt;?php echo form_submit($submit); ?&gt;
&lt;?php
echo form_close();
?&gt;
</td></table>
<div class="content_bottom"></div>
</div>
&lt;?php $this->load->view('right_sidebar.php'); ?&gt;
&lt;?php $this->load->view('footer'); ?&gt;

When I press submit, it has just redirect my od view registration.php. What I am doing wrong? Thank you for your comments.




Theme © iAndrew 2016 - Forum software by © MyBB