from post goes from index.php/form to index.php?form |
[eluser]coderex[/eluser]
Hi, I've just starting learning CI and from the form example in codeigniter when I post, apart from no validation messages it goes from http://mysite.com/codigniter/index.php/form to http://mysite.com/codigniter/index.php?form which displays a completely different page, not the form, why is it showing ? ,?. I think there's some sort of config issue, can anyone give me a hand please? ## controller example in code igniter <?php class Form extends CI_Controller { function index() { $this->load->helper(array('form', 'url')); $this->load->library('Form_validation'); $this->form_validation->set_rules('username', 'Username', 'required'); $this->form_validation->set_rules('password', 'Password', 'required'); $this->form_validation->set_rules('passconf', 'Password Confirmation', 'required'); $this->form_validation->set_rules('email', 'Email', 'required'); if ($this->form_validation->run() == FALSE) { $this->load->view('myform'); } else { $this->load->view('formsuccess'); } } } ?> <html> <head> <title>My Form</title> </head> <body> ## myform <?php echo validation_errors(); ?> <?php echo form_open('form'); ?> <h5>Username</h5> <input type="text" name="username" value="" size="50" /> <h5>Password</h5> <input type="text" name="password" value="" size="50" /> <h5>Password Confirm</h5> <input type="text" name="passconf" value="" size="50" /> <h5>Email Address</h5> <input type="text" name="email" value="" size="50" /> <div><input type="submit" value="Submit" /></div> </form> </body> </html> ## form success <html> <head> <title>My Form</title> </head> <body> <h3>Your form was successfully submitted!</h3> <p><?php echo anchor('form', 'Try it again!'); ?></p> </body> </html>
[eluser]InsiteFX[/eluser]
Code: <?php echo form_open('controller/method');?> InsiteFX
[eluser]coderex[/eluser]
Hi, no still produces a ? e.g if you look at the source code of what form_help.php is producing it's showing http://127.0.0.1/codeigniter/index.php?form/ if I add your suggestion it just shows http://127.0.0.1/codeigniter/index.php?controller/form/ if I do a hardcoded test of and name it something else, it works, so what's the "?" doing there, I don't see how it's placed in form_help.php //## hard coded example below works <form action="http://127.0.0.1/codeigniter/index.php/form/" method="post" accept-charset="utf-8"> <h5>Username</h5> <input type="text" name="username" value="" size="50" /> <h5>Password</h5> <input type="text" name="password" value="" size="50" /> <h5>Password Confirm</h5> <input type="text" name="passconf" value="" size="50" /> <h5>Email Address</h5> <input type="text" name="email" value="" size="50" /> <div><input type="submit" value="Submit" /></div> </form>
[eluser]danmontgomery[/eluser]
form_open() uses base_url. If a ? is showing up, it's in base_url, which is in config/config.php
[eluser]coderex[/eluser]
Actually needed to set 'enable_query_strings' from 'TRUE' to 'FALSE' which true by default, unless I changed it previously, can't remember, but solved now, you got me looking in the area anyway set $config['enable_query_strings'] = FALSE; |
Welcome Guest, Not a member yet? Register Sign In |