justAnoob Posted May 18, 2009 Share Posted May 18, 2009 This script works on all my pages on the site I'm working on....except for 1 page... I don't understand why... Yes,, I have session_start(); at the top of the page. I know this is not in detail,, but maybe someone has had the same prob.. <?php if(isset($_SESSION['auth'])) { unset($_SESSION['message']); sleep(3); echo ($_SESSION['goodlog'] . '<a href="logout.php">Log out'); } else { echo '<form name="form1" method="post" action="login.php"> <input name="username" type="text" id="username" /> <input name="password" type="password" id="password" /> <input type="submit" name="submit" id="submit" value="Login"> </form>'; } ?> Link to comment https://forums.phpfreaks.com/topic/158649-solved-question/ Share on other sites More sharing options...
Ken2k7 Posted May 18, 2009 Share Posted May 18, 2009 Um... what's not working? I can't tell what's wrong if you just posted your code without stating the problem. Saying it doesn't work doesn't mean anything. One thing I see is that the anchor tag is not closed in your echo. Link to comment https://forums.phpfreaks.com/topic/158649-solved-question/#findComment-836703 Share on other sites More sharing options...
justAnoob Posted May 18, 2009 Author Share Posted May 18, 2009 It always shows the log in form(on my problem page) even if I signed in back at the hompage. But all the other pages have this exact same code and they function just fine. Link to comment https://forums.phpfreaks.com/topic/158649-solved-question/#findComment-836705 Share on other sites More sharing options...
keha76 Posted May 18, 2009 Share Posted May 18, 2009 What's the difference between the page not working and the ones that do? More code would be helpful! Link to comment https://forums.phpfreaks.com/topic/158649-solved-question/#findComment-836706 Share on other sites More sharing options...
justAnoob Posted May 18, 2009 Author Share Posted May 18, 2009 That is the problem,, there really isn't one,, the code is identical....The strange thing is that the log in form appears on the page that is having the problem, so I sign in again and it returns me to the homepage. Then if I click on the link again to go back to the problem page, everything is ok... So the scripts only work when I sign in from the problem page. Link to comment https://forums.phpfreaks.com/topic/158649-solved-question/#findComment-836715 Share on other sites More sharing options...
justAnoob Posted May 18, 2009 Author Share Posted May 18, 2009 Here is the problem page form. <form id="form1" name="form1" method="post" action="login.php"> <div align="center"> <div align="center"> <?php if(!isset($_SESSION['auth'])) { echo ($_SESSION['message']); } ?> <?php if(isset($_SESSION['goodreg'])) { unset($_SESSION['message']); echo ($_SESSION['goodreg']); } ?> <br> <?php if(isset($_SESSION['auth'])) { unset($_SESSION['message']); sleep(3); echo ($_SESSION['goodlog'] . '<a href="logout.php">Log out'); } else { echo '<form name="form1" method="post" action="login.php"> <input name="username" type="text" id="username" /> <input name="password" type="password" id="password" /> <input type="submit" name="submit" id="submit" value="Login"> </form>'; } ?> <br /> </div> </div> </form> And here is the form from the homepage and all the other pages that work fine. <form id="form1" name="form1" method="post" action="login.php"> <div align="center"> <div align="center"> <?php if(!isset($_SESSION['auth'])) { echo ($_SESSION['message']); } ?> <?php if(isset($_SESSION['goodreg'])) { unset($_SESSION['message']); echo ($_SESSION['goodreg']); } ?> <br> <?php if(isset($_SESSION['auth'])) { unset($_SESSION['message']); sleep(3); echo ($_SESSION['goodlog'] . '<a href="logout.php">Log out'); } else { echo '<form name="form1" method="post" action="login.php"> <input name="username" type="text" id="username" /> <input name="password" type="password" id="password" /> <input type="submit" name="submit" id="submit" value="Login"> </form>'; } ?> <br /> </div> </div> </form> Link to comment https://forums.phpfreaks.com/topic/158649-solved-question/#findComment-836717 Share on other sites More sharing options...
justAnoob Posted May 18, 2009 Author Share Posted May 18, 2009 This is really strange, or maybe it is something I do not know about... Here is the link on my homepage that takes my to the page that I'm having problems with. <?php echo substr($row['description'],0,50).'<a href="http://------.com/viewitem.php?id_main='.$row['id'].'"> ...View</a>'; ?> With the code above,,, even when I'm signed in and click on the link,, it takes me to the page but as I mentioned earlier in this thread,,, it still shows the log in form... Now check out the code below.... <?php echo '<a href="viewitem.php"><img src="images/my_btn.png" width="91" height="20" border="0">'; ?> Now if I just put in a picture with a link to replace the original code above,, it takes me to the page just fine with no problems.. What is causing the problems with the first line of code??? Link to comment https://forums.phpfreaks.com/topic/158649-solved-question/#findComment-836749 Share on other sites More sharing options...
justAnoob Posted May 18, 2009 Author Share Posted May 18, 2009 figured it out. Link to comment https://forums.phpfreaks.com/topic/158649-solved-question/#findComment-836751 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.