0

I am trying to implement a logging-redirect page without losing the current page's data. I found this answer link interesting, particularly his 3rd option, but I am not understanding how to achieve this. I am using PHP in backend.

Since because my pages been loaded according to the hash value change i believe an ajax via is an only solution

Thanks n advance

Community
  • 1
  • 1
tradebel123
  • 435
  • 1
  • 5
  • 20

1 Answers1

0

You can achieve this by storing data either into a session variable array or temp database table. I would prefer to store it in session.

If you are doing it using session then it can be:

When user clicks on submit, do you check that the user is logged in or not? If yes, then store data into a table. If not, then store it into a session array, say xyz[]. After storing it, redirect the user to a login page. After login, you can check if the session array xyz[] contains any value. If it does, store it into a particular table and don't forget to unset session array xyz[]. Otherwise, redirect user to home.

If you are doing it using the DB then it can be:

When user clicks on submit, do you check that the user is logged in or not? If yes, then store data into db table. If not, then store it into a temporary db table. After storing it, redirect user to login page. After login, you can check if the temp db table contains any record. If it does, then move it into a particular table and don't forget to delete record from the temp db table. Otherwise, redirect user to home.

or else best way

In starting of your form just check if user logged in or not? if not then redirect him to login page. Otherwise, allow them to fill data in form.

Gray
  • 7,050
  • 2
  • 29
  • 52
404 Not Found
  • 1,223
  • 2
  • 22
  • 31
  • thanks for the idea.. in my case my pages are loaded according to the hash changes so the redirecting back to the hash location is very deficult.. do you have any idea to achieve this via ajax calling? – tradebel123 Oct 09 '13 at 12:32
  • save the hash value to the session as well, then retrieve it after login to redirect – joe42 Oct 09 '13 at 14:04
  • no hash value cannot be retrieved by php http://stackoverflow.com/questions/940905 – tradebel123 Oct 09 '13 at 14:44