how can redirect with validate |
[eluser]Kency[/eluser]
Hi ! I have problem when i try validate my form with CI form validate, but i want to redirect when i validate. it mean my url like Code: http://example.com/form and when form is missing it call function checkform() and url will be Code: http://example.com/checkform but i want my url is the same in first url Code: http://example.com/form how can i do it with CI?
[eluser]Abel A.[/eluser]
I'm not sure what you're asking here... but, you can try reading this(scroll to the bottom): http://ellislab.com/codeigniter/user-gui...elper.html
[eluser]Kency[/eluser]
[quote author="berkguy" date="1338446981"]I'm not sure what you're asking here... but, you can try reading this(scroll to the bottom): http://ellislab.com/codeigniter/user-gui...elper.html [/quote] i mean when i submit form, my form call function checkform() from controller. and url will be Code: http://example.com/checkform but i dont want my url like that i need my url the same url with my form Code: http://example.com/form
[eluser]Abel A.[/eluser]
You mean the callback when you use the CI form validation?
[eluser]Kency[/eluser]
[quote author="berkguy" date="1338447337"]You mean the callback when you use the CI form validation?[/quote] ok i post sample code to make sense what i mean Code: url: http://example.com/form and my controller Code: function checkform(){ but i dont want my url change like that, if i use redirect(/form) my form doesn't show any error
[eluser]Abel A.[/eluser]
If you're trying to call another controller, it means your code is not very organized. CI is pretty well structured. Try following this: Code: class Form extends CI_Controller {
[eluser]Abel A.[/eluser]
Also, don't use your controllers as functions for your application. Controller are meant to control your app and call views. If you need to create functions you can use models. Creating functions in your controller can lead to a security risk too. Notice that I added the _ to the checkform function so it's not accessible via url.
[eluser]Kency[/eluser]
thank for your quick reply @berkguy but my form just check some information about user who send his feedback to us. and in my controller has many function it check check some form like that, i wondering how can i check it within index function?
[eluser]Abel A.[/eluser]
That's what I'm talking about, if you're going to re-use a function in your controller, you should move the function to a model. Controllers should only include code that will only be used once. Save yourself the headache and just move the function to a model. It's a little extra work, but it's work it |
Welcome Guest, Not a member yet? Register Sign In |