ana9 Posted December 15, 2006 Share Posted December 15, 2006 I have the following on a page: (I have session_start(); on all pages)<?phpsession_start(); if (isset($_SESSION['auth'])=="yes") { echo "<p> </p><p> </p><p align='center'><font face='verdana'>You are registered.</font></p>";}etc..... ?>so that when a user registers on another page if they hit the back button they cannot register a second time.The person is redirected to a second page where their info is inserted into the mssql database then I call: $_SESSION['auth']="yes"; to set the variableWhen I run this setup on my local machine it works perfectly, however when I put it up on the server it does not work. I am running sqlserver2005, windows server 2003, IIS6, php5. Quote Link to comment Share on other sites More sharing options...
fert Posted December 15, 2006 Share Posted December 15, 2006 [code]if (isset($_SESSION['auth'])=="yes")[/code]should be[code]if ($_SESSION['auth']=="yes")[/code] Quote Link to comment Share on other sites More sharing options...
ana9 Posted December 18, 2006 Author Share Posted December 18, 2006 I had that code originally and I would get an error the first time the page was loaded because there was no value for the variable. By putting in the ISSET it eliminated the error and everything was working fine until I put it on the server. Quote Link to comment Share on other sites More sharing options...
redbullmarky Posted December 18, 2006 Share Posted December 18, 2006 but isset does exactly that - it tells you if a var is set (ie, holds a value). [url=http://www.php.net/isset]isset[/url] returns either true or false. so what your check actually equates to is:if TRUE/FALSE == 'yes'which will always fail.using both a check of being set as well as a check of its value should work:[code]<?phpif (isset($_SESSION['auth']) && $_SESSION['auth'] == "yes")?>[/code]hope that helpsCheersMark Quote Link to comment Share on other sites More sharing options...
ana9 Posted December 18, 2006 Author Share Posted December 18, 2006 That did the trick, thanks Mark. Quote Link to comment Share on other sites More sharing options...
redbullmarky Posted December 18, 2006 Share Posted December 18, 2006 ;) no probs Quote Link to comment 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.