I'm wondering if anyone might be able to help explain how I can pass a variable (session?) from one page to another on the click of a button.
What I have is the main webpage with 2 buttons - Login and Register. When the user clicks on either button at present they are taken to the same login webpage where they can fill in their login details. The problem with this is that users who need to register do not read the accompanying text which gives the default registration username and password so they can login and complete the registration form in the backend database.
What I would like to achieve is that when a user clicks on the register button the default registration username and password are passed to the next page and automatically entered into the relevant fields so the user only has to click on the Login button on that page.
I presume that I need to start the session on the first page and set the variables ($uname and $pwd) somehow when the user clicks on the register button and then pass the contents of the variable to the next page where I can transfer the contents into the relevant fields automatically using an If statement. Could someone please explain how I achieve this?
Would I also be right in assuming that it would be a good idea to clear the variables when the user clicks on the Login button on the second page?
Any assistance with this would be greatly appreciated.
Pass Variable On Click Of Button
Moderator: General Moderators
Try keeping your session variable into HIDDEN field. e.g.
Code: Select all
<input type='HIDDEN' name='session_var' value='$session_var'>- Kieran Huggins
- DevNet Master
- Posts: 3635
- Joined: Wed Dec 06, 2006 4:14 pm
- Location: Toronto, Canada
- Contact:
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA