0

i made a normal form for users to submit data name,email and city in form for this work i use some coding and i still not figure out where i mistaken please suggest.

routes

$route['default_controller'] = "welcome";

welcome.php in controller

public function index()
    {
        $this->load->view('ar_signup');     
        $this->load->helper('url');
    }
}

ar_signup for the form in view

<!DOCTYPE html> 
<html lang="en-US">
  <head>
    <title>Landing Page</title>
    <meta charset="utf-8">
    <link href="assests/css/ar/ar.css" rel="stylesheet" type="text/css">
  </head>
  <body>
        <?php echo validation_errors(); ?>
        <?php echo form_open('user'); ?>
        <label for="name">Name:</label>
        <input type="name" id="name" name="name">   
        <label for="email">Email:</label>       
        <input type="email" id="email" name="email">        
        <label for="city">City:</label>     
        <input type="city" id="city" name="city">       
        <input type="submit" value="Login">     
        </div>      
        </form>     

  </body>
</html> 

user.php in controller

<?php
function create_member()
    {
        $this->load->library('form_validation');        

        // field name, error message, validation rules
        $this->form_validation->set_rules('name', 'Name', 'trim|required');
        $this->form_validation->set_rules('email', 'Email', 'trim|required|valid_email');
        $this->form_validation->set_rules('city', 'City', 'trim|required');     

        if($this->form_validation->run() == FALSE)
        {
            $this->load->view('ar_thanks');
        }
        else
        {           
            $this->load->model('users_model');

            if($query = $this->Users_model->create_member())
            {
                $this->load->view('ar_landing');            
            }

        }

    }

user_model.php mention in models

<?php
function create_member()
    {

        $this->db->where('user_name', $this->input->post('username'));
        $query = $this->db->get('users');

        if($query->num_rows > 0){           
        }else{
            $new_member_insert_data = array(
                'name' => $this->input->post('name'),
                'email' => $this->input->post('email'),
                'city' => $this->input->post('city'),                           
            );
            $insert = $this->db->insert('users', $new_member_insert_data);
            return $insert;
        }

    }//create_member
}
FormaL
  • 359
  • 2
  • 5
  • 19

2 Answers2

0

In Your user.php controller change

if($this->form_validation->run() == FALSE)
    {
        $this->load->view('ar_thanks');
    }

to

if($this->form_validation->run() == FALSE)
    {
        $this->load->view('ar_signup');
    }

In your view file give this: <?php echo form_open('user/create_member'); ?>

Now hit the ur: localhost/landingpage/index.php/user/create_member

user2936213
  • 1,021
  • 1
  • 8
  • 19
0

If your controller is 'welcome' then your url should be 'localhost/welcome'. Also check your mod_rewrite. Edit

I think it will be your php installation, since you said when you removed the php codes, it was working perfectly.

Hubert
  • 169
  • 6