Form submit using wrong path |
[eluser]williamparry[/eluser]
Hi, I have a registration page and the top of the html in the view folder is: Code: <?=form_open('register'); ?> In the controller folder I have: Code: <?php The page is located at: http://127.0.0.1/website/index.php/register When I submit the form, it goes: http://127.0.0.1/website/index.php/regis...p/register Why is appending the index.php again? Thanks
[eluser]Pascal Kriete[/eluser]
Make sure that the 'base_url' in your config file is set correctly. It should be: Code: $config['base_url'] = "http://127.0.0.1/website/";
[eluser]williamparry[/eluser]
Ah that did it! Thanks. It looks as though when I add a form element in the view page, I have to add something related to that element on the control page. Is this correct?
[eluser]Pascal Kriete[/eluser]
The form returns a post array as it does in normal php, but in CI you have the validation class to help you check and process the data. Also instead of accessing the post array directly: Code: $_POST['whatever']; You should use: Code: $this->input->post('whatever'); Hopefully that answers your question.
[eluser]williamparry[/eluser]
I'm a bit confused about how the validation ties in with post. I have: Code: $rules['firstName'] = "trim|required|xss_clean"; If I do Code: $this->input->post('firstName'); Will that give me the post variable with the cleaning and validation done? I've got a registration model set up that is going to deal with the adding and I am not sure how to go about passing the information from the controller to the model. At the moment I am calling the model and running my model's adding function with the argument being $_POST but I don't need some of the fields. Should I do this all by hand and also, can I pass the validated and sanitised post data into the model, rather than raw $_POST without manual coding? Cheers
[eluser]Pascal Kriete[/eluser]
When you run the validation using: Code: $this->validation->run() As for the model, in CodeIgniter the model is simply another layer, unlike in rails where it is tightly connected to the database. You pass data to it the way you would to any other function. It's basically just a place for your database calls. If you have a lot of fields (but don't want all of them) you might consider making an array of those you want to add and then looping through that: Code: $this->load->model('Your_model');
[eluser]nirbhab[/eluser]
hi in your configration file you wud find this line. Code: $config['index_page'] = "index.php"; change it to Code: $config['index_page'] = ""; and try using your form post. it might help you out.
[eluser]williamparry[/eluser]
It doesn't seem to be md5ing my password. Code: $rules['firstName'] = "trim|required|xss_clean"; If I don't put in: Code: $fields['phoneNumber'] It says: A PHP Error was encountered Severity: Notice Message: Undefined property: CI_Validation::$phoneNumber Filename: views/register.php Line Number: 21
[eluser]nirbhab[/eluser]
it will as your view page where you must be refilling the code must be calling this field. n for md5ing, y don't u use md5() ,default php function while storing in database.
|
Welcome Guest, Not a member yet? Register Sign In |