[PHP] UNSETing Session Variables
I am having a slight problem unseting some session variable. here is an exaple of what I have Page1: choice: 1 choice: 2 choice: 3 choice: 4 Click on Submit button after choosing 1, 2, 3, or 4 Page 2: Loads information from previoius choice. Start over again I am using a session variable for choice and am trying at the beginning of page 1 to unset the session variable, but it is never beign over written or rest. Please Help Jed
Re: [PHP] UNSETing Session Variables
unsset($_SESSION['choice']); // .. or .. // session_unregister('choice'); -Kevin - Original Message - From: [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Monday, July 08, 2002 11:54 AM Subject: [PHP] UNSETing Session Variables I am having a slight problem unseting some session variable. here is an exaple of what I have Page1: choice: 1 choice: 2 choice: 3 choice: 4 Click on Submit button after choosing 1, 2, 3, or 4 Page 2: Loads information from previoius choice. Start over again I am using a session variable for choice and am trying at the beginning of page 1 to unset the session variable, but it is never beign over written or rest. Please Help Jed -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] UNSETing Session Variables
I tried to enter the comand as such unset ($_SESSION[choice]); I thought everything in php was double quotes. but even with single quotes it still isn't quite working. If I do it on the first page then it won't let a later command assign anything to the variable, but if I do it on a seperate third page, it doesn't reset anything. I have been trying to avoid unregistering variables and then reseting them. Seems a little too messy for my programming tastes. Jed Kevin Stone [EMAIL PROTECTED] 07/08/2002 12:01 PM To: [EMAIL PROTECTED], [EMAIL PROTECTED] cc: Subject:Re: [PHP] UNSETing Session Variables unsset($_SESSION['choice']); // .. or .. // session_unregister('choice'); -Kevin - Original Message - From: [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Monday, July 08, 2002 11:54 AM Subject: [PHP] UNSETing Session Variables I am having a slight problem unseting some session variable. here is an exaple of what I have Page1: choice: 1 choice: 2 choice: 3 choice: 4 Click on Submit button after choosing 1, 2, 3, or 4 Page 2: Loads information from previoius choice. Start over again I am using a session variable for choice and am trying at the beginning of page 1 to unset the session variable, but it is never beign over written or rest. Please Help Jed -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] UNSETing Session Variables
We're going to need to see some of your code to help you further. -Kevin - Original Message - From: [EMAIL PROTECTED] To: Kevin Stone ; [EMAIL PROTECTED] Sent: Monday, July 08, 2002 12:15 PM Subject: Re: [PHP] UNSETing Session Variables I tried to enter the comand as such unset ($_SESSION[choice]); I thought everything in php was double quotes. but even with single quotes it still isn't quite working. If I do it on the first page then it won't let a later command assign anything to the variable, but if I do it on a seperate third page, it doesn't reset anything. I have been trying to avoid unregistering variables and then reseting them. Seems a little too messy for my programming tastes. Jed Kevin Stone [EMAIL PROTECTED] 07/08/2002 12:01 PM To:[EMAIL PROTECTED], [EMAIL PROTECTED] cc: Subject:Re: [PHP] UNSETing Session Variables unsset($_SESSION['choice']); // .. or .. // session_unregister('choice'); -Kevin - Original Message - From: [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Monday, July 08, 2002 11:54 AM Subject: [PHP] UNSETing Session Variables I am having a slight problem unseting some session variable. here is an exaple of what I have Page1: choice: 1 choice: 2 choice: 3 choice: 4 Click on Submit button after choosing 1, 2, 3, or 4 Page 2: Loads information from previoius choice. Start over again I am using a session variable for choice and am trying at the beginning of page 1 to unset the session variable, but it is never beign over written or rest. Please Help Jed -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] UNSETing Session Variables
I more or less figured that. below is the code for the two pages in question. Page 1: ? require(connect.inc); unset ($_SESSION['currentbid']); ? HEAD TITLE/TITLE /HEAD BODY Borrowers TABLE BORDER=1 TR ? /* Get all users select call */ $users = mysql_query(SELECT bname, bphone, address, admin, bid FROM Borrowers ORDER BY bname); echo TH; echo Name; echo /TH; echo TH; echo Phone; echo /TH; echo TH; echo Address; echo /TH; echo TH; echo Admin; echo /TH; echo TR; if($users) while($row=mysql_fetch_row($users)) { echo TR; echo TD $row[0] /TD; echo TD $row[1] /TD; echo TD $row[2] /TD; if($row[3]) echo TD Yes /TD; else echo TD No /TD; print TD FORM METHOD=\post\ action=\uupdate.php\ input type=\hidden\ name=\ubid\ value=\$row[4]\ INPUT TYPE=\SUBMIT\ VALUE=\Change User.\ /FORM /TD; print TD FORM METHOD=\post\ action=\udelete.php\ input type=\hidden\ name=\ubid\ value=\$row[4]\ INPUT TYPE=\SUBMIT\ VALUE=\Delete User.\ /FORM /TD; print TD FORM METHOD=\post\ action=\uadmin.php\ input type=\hidden\ name=\ubid\ value=\$row[4]\ INPUT TYPE=\SUBMIT\ VALUE=\Make Admin.\ /FORM /TD; echo /TR\n; } ? /TR /TABLE ? require(tail.inc) ? page2: ? require(connect.inc); ? HEAD TITLE User Update Page /TITLE /HEAD BODY BR BR ? print $currentbid-current, $ubid-change, $bid-current; ? ? if($admin) $currentbid = $ubid; else $currentbid = $bid; $result = mysql_query(SELECT bname, bphone, address FROM Borrowers Where bid=$currentbid); if($result) { $row = mysql_fetch_row($result); $oname = $row[0]; $ophone = $row[1]; $oaddress = $row[2]; } ? Please enter the new information into the fields below. TABLE BORDER TRTH Current Information /TH/TR TRTHFORM method=post action=ucupdate.php INPUT TYPE=text NAME=uname value=?print '$oname'? SIZE=30/TH THINPUT TYPE=text NAME=uphone value=?print $ophone? SIZE=30/TH THINPUT TYPE=text NAME=uaddress value=?print '$oaddress'? SIZE=30/TH/TR ? if($admin) { print THINPUT TYPE=\text\ NAME=\upassword\ value=; $cpass = mysql_query(SELECT admin_pass FROM Borrowers WHERE bid=$currentbid); $cpassr = mysql_fetch_row($cpass); print \$cpassr[0]\ ; print SIZE=\30\/TH/TR; } ? /TABLE INPUT TYPE=SUBMIT VALUE=Submit your information. INPUT TYPE=RESET VALUE=Clear /FORM ? require(tail.inc); ? The first page gives the admin user a list of users, and three options (change their information, delete them, or make them and Admin). The option we are choosing is to change information. If I select user number 1 the only way to edit another user is to log out and log back in. If any of the code is unclear please let me know. I haven't gotten to commenting it all yet. Jed Kevin Stone [EMAIL PROTECTED] 07/08/2002 12:47 PM To: [EMAIL PROTECTED] cc: Subject:Re: [PHP] UNSETing Session Variables We're going to need to see some of your code to help you further. -Kevin - Original Message - From: [EMAIL PROTECTED] To: Kevin Stone ; [EMAIL PROTECTED] Sent: Monday, July 08, 2002 12:15 PM Subject: Re: [PHP] UNSETing Session Variables I tried to enter the comand as such unset ($_SESSION[choice]); I thought everything in php was double quotes. but even with single quotes it still isn't quite working. If I do it on the first page then it won't let a later command assign anything to the variable, but if I do it on a seperate third page, it doesn't reset anything. I have been trying to avoid unregistering variables and then reseting them. Seems a little too messy for my programming tastes. Jed Kevin Stone [EMAIL PROTECTED] 07/08/2002 12:01 PM To:[EMAIL PROTECTED], [EMAIL PROTECTED] cc: Subject:Re: [PHP] UNSETing Session Variables unsset($_SESSION['choice']); // .. or .. // session_unregister('choice'); -Kevin - Original Message - From: [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Monday, July 08, 2002 11:54 AM Subject: [PHP] UNSETing Session Variables I am having a slight problem unseting some session variable. here is an exaple of what I have Page1: choice: 1 choice: 2 choice: 3 choice: 4 Click on Submit button after choosing 1, 2, 3, or 4 Page 2: Loads information from previoius choice. Start over again I am using a session variable for choice and am trying at the beginning of page 1 to unset the session variable, but it is never beign over written or rest. Please Help Jed -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] UNSETing Session Variables
$_SESSION['currentbid'] isn't available until you do session_start(); session_start(); unset($_SESSION['currentbid']); Or is this what does connect.inc contains? -Kevin - Original Message - From: [EMAIL PROTECTED] To: Kevin Stone Cc: [EMAIL PROTECTED] Sent: Monday, July 08, 2002 1:43 PM Subject: Re: [PHP] UNSETing Session Variables I more or less figured that. below is the code for the two pages in question. Page 1: ? require(connect.inc); unset ($_SESSION['currentbid']); ? HEAD TITLE/TITLE /HEAD BODY Borrowers TABLE BORDER=1 TR ? /* Get all users select call */ $users = mysql_query(SELECT bname, bphone, address, admin, bid FROM Borrowers ORDER BY bname); echo TH; echo Name; echo /TH; echo TH; echo Phone; echo /TH; echo TH; echo Address; echo /TH; echo TH; echo Admin; echo /TH; echo TR; if($users) while($row=mysql_fetch_row($users)) { echo TR; echo TD $row[0] /TD; echo TD $row[1] /TD; echo TD $row[2] /TD; if($row[3]) echo TD Yes /TD; else echo TD No /TD; print TD FORM METHOD=\post\ action=\uupdate.php\ input type=\hidden\ name=\ubid\ value=\$row[4]\ INPUT TYPE=\SUBMIT\ VALUE=\Change User.\ /FORM /TD; print TD FORM METHOD=\post\ action=\udelete.php\ input type=\hidden\ name=\ubid\ value=\$row[4]\ INPUT TYPE=\SUBMIT\ VALUE=\Delete User.\ /FORM /TD; print TD FORM METHOD=\post\ action=\uadmin.php\ input type=\hidden\ name=\ubid\ value=\$row[4]\ INPUT TYPE=\SUBMIT\ VALUE=\Make Admin.\ /FORM /TD; echo /TR\n; } ? /TR /TABLE ? require(tail.inc) ? page2: ? require(connect.inc); ? HEAD TITLE User Update Page /TITLE /HEAD BODY BR BR ? print $currentbid-current, $ubid-change, $bid-current; ? ? if($admin) $currentbid = $ubid; else $currentbid = $bid; $result = mysql_query(SELECT bname, bphone, address FROM Borrowers Where bid=$currentbid); if($result) { $row = mysql_fetch_row($result); $oname = $row[0]; $ophone = $row[1]; $oaddress = $row[2]; } ? Please enter the new information into the fields below. TABLE BORDER TRTH Current Information /TH/TR TRTHFORM method=post action=ucupdate.php INPUT TYPE=text NAME=uname value=?print '$oname'? SIZE=30/TH THINPUT TYPE=text NAME=uphone value=?print $ophone? SIZE=30/TH THINPUT TYPE=text NAME=uaddress value=?print '$oaddress'? SIZE=30/TH/TR ? if($admin) { print THINPUT TYPE=\text\ NAME=\upassword\ value=; $cpass = mysql_query(SELECT admin_pass FROM Borrowers WHERE bid=$currentbid); $cpassr = mysql_fetch_row($cpass); print \$cpassr[0]\ ; print SIZE=\30\/TH/TR; } ? /TABLE INPUT TYPE=SUBMIT VALUE=Submit your information. INPUT TYPE=RESET VALUE=Clear /FORM ? require(tail.inc); ? The first page gives the admin user a list of users, and three options (change their information, delete them, or make them and Admin). The option we are choosing is to change information. If I select user number 1 the only way to edit another user is to log out and log back in. If any of the code is unclear please let me know. I haven't gotten to commenting it all yet. Jed Kevin Stone [EMAIL PROTECTED] 07/08/2002 12:47 PM To:[EMAIL PROTECTED] cc: Subject:Re: [PHP] UNSETing Session Variables We're going to need to see some of your code to help you further. -Kevin - Original Message - From: [EMAIL PROTECTED] To: Kevin Stone ; [EMAIL PROTECTED] Sent: Monday, July 08, 2002 12:15 PM Subject: Re: [PHP] UNSETing Session Variables I tried to enter the comand as such unset ($_SESSION[choice]); I thought everything in php was double quotes. but even with single quotes it still isn't quite working. If I do it on the first page then it won't let a later command assign anything to the variable, but if I do it on a seperate third page, it doesn't reset anything. I have been trying to avoid unregistering variables and then reseting them. Seems a little too messy for my programming tastes. Jed Kevin Stone [EMAIL PROTECTED] 07/08/2002 12:01 PM To:[EMAIL PROTECTED], [EMAIL PROTECTED] cc: Subject:Re: [PHP] UNSETing Session Variables unsset($_SESSION['choice']); // .. or .. // session_unregister('choice
Re: [PHP] UNSETing Session Variables
Sorry about that I should have been more detailed. session_start() and all of my session_register() calls happen on login.php here is a sample session_register call. session_register(currentbid); I am under the impression that I only need one session register call. Jed Kevin Stone [EMAIL PROTECTED] 07/08/2002 02:00 PM To: [EMAIL PROTECTED] cc: [EMAIL PROTECTED] Subject:Re: [PHP] UNSETing Session Variables $_SESSION['currentbid'] isn't available until you do session_start(); session_start(); unset($_SESSION['currentbid']); Or is this what does connect.inc contains? -Kevin - Original Message - *snip please see previous messages for this information snip*
Re: [PHP] UNSETing Session Variables
I fear you're missing something fundemental here. The active session needs to be requested for each script. So session_start() needs to be called at the top of each script (or at least before any output). Example.. page 1 -- ? session_start(); $myvar = foo bar; session_register('myvar'); // or // $_SESSION['myvar'] = $myvar; ? page 2 - ? session_start(); unset($_SESSION['myvar']; // or // session_unregister('myvar'); ? - Original Message - From: [EMAIL PROTECTED] To: Kevin Stone Cc: [EMAIL PROTECTED] ; [EMAIL PROTECTED] Sent: Monday, July 08, 2002 2:05 PM Subject: Re: [PHP] UNSETing Session Variables Sorry about that I should have been more detailed. session_start() and all of my session_register() calls happen on login.php here is a sample session_register call. session_register(currentbid); I am under the impression that I only need one session register call. Jed Kevin Stone [EMAIL PROTECTED] 07/08/2002 02:00 PM To:[EMAIL PROTECTED] cc:[EMAIL PROTECTED] Subject:Re: [PHP] UNSETing Session Variables $_SESSION['currentbid'] isn't available until you do session_start(); session_start(); unset($_SESSION['currentbid']); Or is this what does connect.inc contains? -Kevin - Original Message - *snip please see previous messages for this information snip*
Re: [PHP] UNSETing Session Variables
You only have to register the session variables once. If you need to register the same variables again (such as for a different user), then you should use session_destroy() before registering the variables again. The variables should be available throughout your pages as long as session_start() is done before ANY output goes to the HTML. It's usually best to have it as the FIRST thing on your pages. Martin [EMAIL PROTECTED] 07/08/02 04:19PM /me feels kinda dumb now. Well even after adding session_start to my connect.inc, it doesn't work. I only need to do session_register() once correct? Or do I need to do that everytime I do session start? If I have to do it everytime then what is the point of sessions? Jed Kevin Stone [EMAIL PROTECTED] 07/08/2002 02:12 PM To: [EMAIL PROTECTED], [EMAIL PROTECTED] cc: Subject:Re: [PHP] UNSETing Session Variables I fear you're missing something fundemental here. The active session needs to be requested for each script. So session_start() needs to be called at the top of each script (or at least before any output). Example.. page 1 -- ? session_start(); $myvar = foo bar; session_register('myvar'); // or // $_SESSION['myvar'] = $myvar; ? page 2 - ? session_start(); unset($_SESSION['myvar']; // or // session_unregister('myvar'); ? - Original Message - From: [EMAIL PROTECTED] To: Kevin Stone Cc: [EMAIL PROTECTED] ; [EMAIL PROTECTED] Sent: Monday, July 08, 2002 2:05 PM Subject: Re: [PHP] UNSETing Session Variables Sorry about that I should have been more detailed. session_start() and all of my session_register() calls happen on login.php here is a sample session_register call. session_register(currentbid); I am under the impression that I only need one session register call. Jed Kevin Stone [EMAIL PROTECTED] 07/08/2002 02:00 PM To:[EMAIL PROTECTED] cc:[EMAIL PROTECTED] Subject:Re: [PHP] UNSETing Session Variables $_SESSION['currentbid'] isn't available until you do session_start(); session_start(); unset($_SESSION['currentbid']); Or is this what does connect.inc contains? -Kevin - Original Message - *snip please see previous messages for this information snip* -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php