Moron Posted August 28, 2007 Share Posted August 28, 2007 Page 1: The user logs in with employee number and password (their SSN). Page 2: A main menu displays with Leave History, Paystubs, and Dental reimbursement. These pages work individually, but how can I link back to the main menu by passing their employee number and SSN back there, without making them have to log in again? I've tried several methods of $_POST and $_GET. No luck so far. Quote Link to comment https://forums.phpfreaks.com/topic/67065-solved-_post-_get-sessions-and-the-back-button/ Share on other sites More sharing options...
Jessica Posted August 28, 2007 Share Posted August 28, 2007 Well, use sessions, like you mentioned in the title. Quote Link to comment https://forums.phpfreaks.com/topic/67065-solved-_post-_get-sessions-and-the-back-button/#findComment-336300 Share on other sites More sharing options...
Moron Posted August 28, 2007 Author Share Posted August 28, 2007 Well, use sessions, like you mentioned in the title. I'm using sessions. For example, on the main menu page, I establish sessions so that they can click the other three pages and these pass fine. For some reason, though, I'm having a problem passing them back to the main menu page. In other words, they're passing forward just fine but I can't seem to get them to pass back. Do I need to convert a session variable back into a $_POST variable at some point? Quote Link to comment https://forums.phpfreaks.com/topic/67065-solved-_post-_get-sessions-and-the-back-button/#findComment-336305 Share on other sites More sharing options...
Jessica Posted August 28, 2007 Share Posted August 28, 2007 What? What do you mean pass back? We need a specific example with code. Quote Link to comment https://forums.phpfreaks.com/topic/67065-solved-_post-_get-sessions-and-the-back-button/#findComment-336319 Share on other sites More sharing options...
Moron Posted August 28, 2007 Author Share Posted August 28, 2007 What? What do you mean pass back? We need a specific example with code. For example, after they've logged in, employeeinformationmenu.php has the following at the top: session_start(); $_SESSION['password'] = $_POST['password']; $_SESSION['empcode'] = $_POST['empcode']; From there, they can click on Dental/Vision/Hearing, which is dentalvisionhearing.php. At the top, dentalvisionhearing.php has: session_start(); $empcode = $_POST['EMPNO']; $_SESSION['empcode']=$empcode; $SESSION['password'] = $_POST['password']; So how can I make a proper link back to employeeinformationmenu.php? Does the link back need to be a form, possibly? By the way, my query in employeeinformationmenu.php contains: WHERE ((M2.[EMPNO] = '".$_POST['empcode']."' and M2.[MSSNO] = '".$_POST['password']."') or (M2.[MSSNO] = '".$_SESSION['password']."' and M2.[EMPNO] = '".$_SESSION['empcode']."')) When I use the link back to employeeinformationmenu.php, it goes to the "die" part. I know the input is right or it wouldn't have given me anything in employeeinformationmenu.php in the first place. So I'm thinking that something isn't carrying over properly in my sessions. Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/67065-solved-_post-_get-sessions-and-the-back-button/#findComment-336345 Share on other sites More sharing options...
MadTechie Posted August 28, 2007 Share Posted August 28, 2007 For example, after they've logged in, employeeinformationmenu.php has the following at the top: session_start(); $_SESSION['password'] = $_POST['password']; $_SESSION['empcode'] = $_POST['empcode']; just a little note.. if you goto the page with the above code and you have NOT summited a post your wipeout the sessions, (over write with nothing) try this session_start(); if(isset($_POST['password'])) {$_SESSION['password'] = $_POST['password'];} if(isset($_POST['empcode'])) {$_SESSION['empcode'] = $_POST['empcode'];} Quote Link to comment https://forums.phpfreaks.com/topic/67065-solved-_post-_get-sessions-and-the-back-button/#findComment-336350 Share on other sites More sharing options...
Jessica Posted August 28, 2007 Share Posted August 28, 2007 Why does dental have the $_POST stuff? Once you store something in the session you don't have to keep setting it again. And what die part? Also $SESSION is wrong, it's $_SESSION. Quote Link to comment https://forums.phpfreaks.com/topic/67065-solved-_post-_get-sessions-and-the-back-button/#findComment-336351 Share on other sites More sharing options...
Moron Posted August 28, 2007 Author Share Posted August 28, 2007 For example, after they've logged in, employeeinformationmenu.php has the following at the top: session_start(); $_SESSION['password'] = $_POST['password']; $_SESSION['empcode'] = $_POST['empcode']; just a little note.. if you goto the page with the above code and you have NOT summited a post your wipeout the sessions, (over write with nothing) try this session_start(); if(isset($_POST['password'])) {$_SESSION['password'] = $_POST['password'];} if(isset($_POST['empcode'])) {$_SESSION['empcode'] = $_POST['empcode'];} That did the trick. Now I can go "back" (with a link) to employeeinformationmenu.php without losing the session. Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/67065-solved-_post-_get-sessions-and-the-back-button/#findComment-336356 Share on other sites More sharing options...
Moron Posted August 28, 2007 Author Share Posted August 28, 2007 Why does dental have the $_POST stuff? Once you store something in the session you don't have to keep setting it again. And what die part? Also $SESSION is wrong, it's $_SESSION. The $_POST was from some older code when I was just starting with php and was even more clueless than I am now! As for the "die" part, it basically brings up some instructions if they get their employee number or SSN wrong, or of they don't match. Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/67065-solved-_post-_get-sessions-and-the-back-button/#findComment-336361 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.