contact form guidance [just started] |
[eluser]Met[/eluser]
Hi. Please find below code for my first attempt at a CI app, a very basic contact form. It works, but I get the impression I haven't done it "correctly", or there are far better ways to go about it. Code: <?php How else could I go about achieving this? The idea of setting an $include variable seems, somewhat primitive? Thanks.
[eluser]CroNiX[/eluser]
You can get rid of all of this and put the xss_clean in the rules. Code: $name = $this->input->xss_clean($this->input->post('name')); Code: $this->form_validation->set_rules('name', 'Name', 'required|xss_clean'); Code: $this->form_validation->set_rules('name', 'Name', 'trim|required|xss_clean'); Im not sure what you are doing with your $include, but I would replace that line and just load a new view upon validation failure. Additionally I would add the header before validation, since you will load it upon both pass and fail. Same with the footer, but put under your validation clauses. Something like: Code: //load header Sorry if some of this doesn't make sense, but I wasn't exactly sure what you were doing with your "include". Hopefully this will help though.
[eluser]Met[/eluser]
thanks that's clarified things considerably. with regards to the $include, I have a view called "body" that looks like: Code: <div id="content"> so by passing Code: $data['include']='path/to/my/content'); Appeared to create a some what "dynamic" template for me. No doubt far better ways to implement this. Thanks again |
Welcome Guest, Not a member yet? Register Sign In |