Grego Posted June 5, 2007 Share Posted June 5, 2007 This may be really obvious but I can't get my head around it... At start of document: <? session_start(); if (session_is_registered(myusername)) {$reg=1;} else {$reg=0;} ?> ...In middle of document: <? if ($reg=0) {echo '<a href="login.php">Login</a>';} else {echo '<a href="area.php">Your Area</a> | <a href="logout.php">Logout</a>';} ?> This always shows the second message ("Your Area | Log Out"). What am I doing wrong? Link to comment https://forums.phpfreaks.com/topic/54292-solved-what-am-i-doing-wrong/ Share on other sites More sharing options...
unidox Posted June 5, 2007 Share Posted June 5, 2007 What is wrong. Is the else always showing even though your not logged in? Link to comment https://forums.phpfreaks.com/topic/54292-solved-what-am-i-doing-wrong/#findComment-268419 Share on other sites More sharing options...
Grego Posted June 5, 2007 Author Share Posted June 5, 2007 Yes. It always shows as if I am logged in. Even when I'm definately not. Link to comment https://forums.phpfreaks.com/topic/54292-solved-what-am-i-doing-wrong/#findComment-268422 Share on other sites More sharing options...
unidox Posted June 5, 2007 Share Posted June 5, 2007 1. Can you post more code and 2. Are you using cookies? Link to comment https://forums.phpfreaks.com/topic/54292-solved-what-am-i-doing-wrong/#findComment-268426 Share on other sites More sharing options...
conker87 Posted June 5, 2007 Share Posted June 5, 2007 <? if ($reg=0) {echo '<a href="login.php">Login</a>';} else {echo '<a href="area.php">Your Area</a> | <a href="logout.php">Logout</a>';} ?> Change to: <? if ($reg==0) {echo '<a href="login.php">Login</a>';} else {echo '<a href="area.php">Your Area</a> | <a href="logout.php">Logout</a>';} ?> I think that might work. Link to comment https://forums.phpfreaks.com/topic/54292-solved-what-am-i-doing-wrong/#findComment-268427 Share on other sites More sharing options...
unidox Posted June 5, 2007 Share Posted June 5, 2007 Conker, I am a bit new to php, what dfoes the B have to do with it? Link to comment https://forums.phpfreaks.com/topic/54292-solved-what-am-i-doing-wrong/#findComment-268428 Share on other sites More sharing options...
Grego Posted June 5, 2007 Author Share Posted June 5, 2007 Oh dear Thanks conker. That'll teach me to use two coding languages at once (in seperate programs, of course). Link to comment https://forums.phpfreaks.com/topic/54292-solved-what-am-i-doing-wrong/#findComment-268433 Share on other sites More sharing options...
conker87 Posted June 5, 2007 Share Posted June 5, 2007 I was trying to make it bold. It's changed now. If you're making a variable equal to something (i.e. you are setting it) then use one equal sign = If you're checking to see if a variable is equal to something (through an if statement etc) then use 2 equal signs. == Link to comment https://forums.phpfreaks.com/topic/54292-solved-what-am-i-doing-wrong/#findComment-268435 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.