Hi Everyone,
I have a page which retrieving data from a table. For example: Event page which displays a specific event.
And now I would like to add a url link in this page. If user clicks on it, it takes user to FundEvent page.
FundEvent page contains a form. Using this form I want to collect data and store in a table FUND_EVENT table.
But FUND_EVENT table has event_id field as well. So When user travelling from Event page to FundEvent page, I would like to pass event_id. So that its easy for me to store in FUND_EVENT table.
How can I achieve this?
Could you please suggest me?
Thank you
Hi,
I am storing the data in session variable. Is it fine? Are there any drawbacks if I use it?
Please help me with this.
Thank you,
Srini
junxiong
(Garry3peace)
March 7, 2011, 3:47am
3
I don’t know what is the best practice
but I have met this kind of situation of yours. And usually I would go with Yii’s session
in your event page
Yii::app()->user->setState('event_id', $value);
in the FUND_EVENT table
if(Yii::app()->user->hasState('event_id'))
$value = Yii::app()->user->event_id;
else
$value = $defaultValue;
outrage
(Site Sense Web)
March 8, 2011, 2:50am
5
Potential problem:
View webpage with ‘event’ which has id 1
event.id = 1
session[‘event’] = event.id (1 )
now click fund_event link
complete the form
fund_event form details submitted
fund_event.event_id (the foreign key) = session[‘event’] (1 )
redirect to events page
NOW REPEAT
View page with ‘event’ which has id 2
event.id = 2
session[‘event’] = event.id (2 )
now click fund_event link
complete the form
fund_event form details submitted
fund_event.event_id (the foreign key) = session[‘event’] (2 )
redirect to events page
NOTHING WRONG UP TO NOW
BUT HIT BROWSER BACK BUTTON (shows fund_event page for event.id=session[‘event’] (which is 2 ))
HIT BROWSER BACK BUTTON AGAIN (shows event page for event id 2 )
STILL OK
BUT HIT BROWSER BACK BUTTON AGAIN (shows events page)
HIT BROWSER BACK BUTTON AGAIN (shows fund_event page for event.id=session[‘event’] (which is STILL 2 ))
HIT SUBMIT BUTTON
YOU SEE THE ERROR?
YOU JUST SUBMITTED A FORM WITH DATA RELATING TO EVENT WITH ID 1 , BUT THE SESSION STILL THINKS THE EVENT ID is 2
THEREFORE, THE fund_event DATA YOU SUBMITTED FOR EVENT WITH ID 2 HAS BEEN SAVED AS EVENT WITH ID 1 FROM PREVIOUS POST DATA
Yikes, I hope that’s understandable lol.