Hej, jeg er igang med codeigniter, men jeg har et lille problem og det er at jeg godt kan oprette den samme bruger 2 gange, og jeg kan ikke få den til at gå over på en side som hedder "oprettet.php", altså en view fil.
her er min kode, håber i kan se hva jeg gør galt
- <?php
-
- class Signup extends Controller {
-
- public function __construct() {
- parent::Controller();
- $this->load->library('form_validation');
- }
-
- public function index() {
- $data['content'] = 'create_user_view';
- $this->load->view('includes/template', $data);
- }
-
- public function submit() {
-
- if ($this->_submit_validate() === FALSE) {
- $this->index();
- return;
- }
-
- $this->db->where('username', $this->input->post('username'));
- $this->db->where('password', md5($this->input->post('password')));
- $query = $this->db->get('users');
-
- if($query->num_rows == 0)
- {
- $new_member_insert_data = array(
- 'fornavn' => $this->input->post('fornavn'),
- 'efternavn' => $this->input->post('efternavn'),
- 'email' => $this->input->post('email'),
- 'hood' => $this->input->post('hood'),
- 'city' => $this->input->post('city'),
- 'username' => $this->input->post('username'),
- 'password' => md5($this->input->post('password'))
- );
-
- $insert = $this->db->insert('users', $new_member_insert_data);
- return $insert;
- redirect('oprettet_view');
- //$data['content'] = 'oprettet_view';
- //$this->load->view('includes/template', $data);
- } else {
- return FALSE;
-
- }
-
- }
-
- private function _submit_validate() {
-
- // validation rules
- $this->form_validation->set_rules('fornavn', 'Fornavn',
- 'required|alpha_numeric|min_length[2]|max_length[30]');
-
- $this->form_validation->set_rules('efternavn', 'Efternavn',
- 'required|alpha_numeric|min_length[2]|max_length[70]');
-
- $this->form_validation->set_rules('hood', 'Hood',
- 'required|numeric|min_length[4]|max_length[4]');
-
- $this->form_validation->set_rules('city', 'City',
- 'required|min_length[4]|max_length[90]');
-
- $this->form_validation->set_rules('username', 'Username',
- 'required|alpha_numeric|min_length[6]|max_length[12]');
-
- $this->form_validation->set_rules('username', 'Username',
- 'required|alpha_numeric|min_length[6]|max_length[12]');
-
- $this->form_validation->set_rules('password', 'Password',
- 'required|min_length[6]|max_length[12]');
-
-
- $this->form_validation->set_rules('email', 'E-mail',
- 'required|valid_email');
-
- return $this->form_validation->run();
-
- }
- }