validation not working |
[eluser]diasansley[/eluser]
hello i have used the same validation example from here http://ellislab.com/codeigniter/user-gui...ation.html but when i click submit my URL changes to example.com/index.php/form. can somebody help me out with this please Thanks
[eluser]pickupman[/eluser]
Edit your /application/config/config.php to point to the correct url in $config['base_url'] to your domain name.
[eluser]diasansley[/eluser]
i have changed it to the foll http://localhost/CodeIgniter/ where CodeIgniter is the folder when i click submit it redirects to http://localhost/CodeIgniter/form but form is my controller Any help will be appreciated Thanks
[eluser]pickupman[/eluser]
You can have Codeigniter in a subfolder. You will need to have .htaccess in your /CodeIgniter folder to point to index.php since you have removed it from your urls. Code: RewriteEngine On Now for your form based on the link you show, you should have this in your view Code: echo form_open('form'); In your controller Code: class Form extends Controller{
[eluser]diasansley[/eluser]
here is the code now it says page cannot be found plz help <?php class Form extends Controller{ function _construct(){ parent::Controller(); } } function index() { $this->load->helper(array('form', 'url')); $this->load->library('validation'); $rules['username'] = "callback_username_check"; $rules['password'] = "required"; $rules['passconf'] = "required"; $rules['email'] = "required"; $this->validation->set_rules($rules); if ($this->validation->run() == FALSE) { $this->load->view('myform'); } else { $this->load->view('formsuccess'); } } function username_check($str) { if ($str == 'test') { $this->validation->set_message('username_check', 'The %s field can not be the word "test"'); return FALSE; } else { return TRUE; } } ?>
[eluser]pickupman[/eluser]
Glad you got it working. Please note that the validation library has been deprecated 1.7.2 (removed in 2.0beta). You should form_validation library instead. Also, it may be wise to set your username_check to a private method, as someone could visit that page right now. Or change your syntax to Code: $this->form_validation->set_rules('username', 'username', 'required|trim|callback__username_check'); Also for those of us helping, using the code button in the editor will format your code so we can copy and paste it.
[eluser]diasansley[/eluser]
i have anoter question i wan to display that "PAGE in IMPERTINENCE" when ever a user clicks on a link that has not yet designed . say in the view can i use the anchor tag as well? Thanks rgds
[eluser]pickupman[/eluser]
Sure you can load the url helper, and use anchor(). Links not yet completed will show a CI 404 error. |
Welcome Guest, Not a member yet? Register Sign In |