CodeIgniter Forums
FORM / Redirection help required! - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: FORM / Redirection help required! (/showthread.php?tid=59366)



FORM / Redirection help required! - El Forum - 09-26-2013

[eluser]cidevelopment[/eluser]
Hello Community,

Following is scenario.

SCENARIO 1 :

Suppose I am adding property with following link

/property/add

I implemented server side validation. If there is something wrong with form. It come back to same page

/property/add and loses entered data.

Question 1 > How to retain form value?

SCENARIO 2 :

I need to add room against property. URL is

/property/addroom/12 where 12 is property id.

> If form fails , it should come back to /property/addroom/12 rather than /property/addroom
> When it is successfull it should come back to /property/room/12 to list specific property rooms listing.


Please guide step by step.

Thanks.





FORM / Redirection help required! - El Forum - 09-26-2013

[eluser]Zack K.[/eluser]
[quote author="cidevelopment" date="1380199946"]Hello Community,

Following is scenario.

SCENARIO 1 :

Suppose I am adding property with following link

/property/add

I implemented server side validation. If there is something wrong with form. It come back to same page

/property/add and loses entered data.

Question 1 > How to retain form value?

SCENARIO 2 :

I need to add room against property. URL is

/property/addroom/12 where 12 is property id.

> If form fails , it should come back to /property/addroom/12 rather than /property/addroom
> When it is successfull it should come back to /property/room/12 to list specific property rooms listing.


Please guide step by step.

Thanks.


[/quote]

Are you using codeigniter's form validation or a home brew one?


FORM / Redirection help required! - El Forum - 09-26-2013

[eluser]jairoh_[/eluser]
[quote author="cidevelopment" date="1380199946"]Hello Community,

Following is scenario.

SCENARIO 1 :

Suppose I am adding property with following link

/property/add

I implemented server side validation. If there is something wrong with form. It come back to same page

/property/add and loses entered data.

Question 1 > How to retain form value?

SCENARIO 2 :

I need to add room against property. URL is

/property/addroom/12 where 12 is property id.

> If form fails , it should come back to /property/addroom/12 rather than /property/addroom
> When it is successfull it should come back to /property/room/12 to list specific property rooms listing.


Please guide step by step.

Thanks.


[/quote]
SCENARIO 1:
if you're using CI's Form Validation library class, in your form u can add set_value()
ex.
Code:
form_input( 'username', set_value( 'username' ) );

SCENARIO 2:
sir i would like to tell you that you should not use $_GET/uri values in inserting a data, instead use $_POST for security purposes. $_GET is just intended for getting data not posting Smile


hope this helps.


FORM / Redirection help required! - El Forum - 09-30-2013

[eluser]cidevelopment[/eluser]
Thanks, it worked fine.
Code:
form_input( 'username', set_value( 'username' ) );



FORM / Redirection help required! - El Forum - 10-01-2013

[eluser]boltsabre[/eluser]
Quote:sir i would like to tell you that you should not use $_GET/uri values in inserting a data, instead use $_POST for security purposes. $_GET is just intended for getting data not posting

In terms of security using $_GET (aka $this->uri->segment(3)) or $_POST (aka a hidden input) makes no difference as BOTH are open to manipulation by users.

Whatever method you use you should still validate/cleanse ALL variables that you do not explicitly set yourself. This includes stuff like the values the $_SERVER and $_COOKIES superglobal variables, etc.