Welcome Guest, Not a member yet? Register   Sign In
FORM / Redirection help required!
#1

[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.


#2

[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?
#3

[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.
#4

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

[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.




Theme © iAndrew 2016 - Forum software by © MyBB