chanfuterboy Posted March 15, 2007 Share Posted March 15, 2007 Is easy i know, someone can help me out. When a person is not login in, i want to display >>login<< and when the person is login show >> see it << Ok the second part i can do, thus see it, but the first of login not. <? include("classes/core.inc.php"); $obj = new core; session_start(); include_once("classes/core.inc.php"); ?> <b><font color="#CC3300"><a href="awa.php">>>Login<<</a></font></b> <? if(session_is_registered('user')) { ?> <a href="http://www.domain.com/nos-potret/testcop-4.1.php?album=216&page=1">>>see it<< </a> <? } ?> Link to comment https://forums.phpfreaks.com/topic/42877-problem-with-else-if/ Share on other sites More sharing options...
per1os Posted March 15, 2007 Share Posted March 15, 2007 First of all especially with links [ code ] and [ /code ] are your best friends. Without it, it is very very hard to see the actualy data. <? include("classes/core.inc.php"); $obj = new core; session_start(); include_once("classes/core.inc.php"); if(isset($_SESSION['user']) { print 'see it code here'; }else { print 'login code here'; } ?> make sure you are using session_start(); and assign the $_SESSION['user'] a value when you get that data. Link to comment https://forums.phpfreaks.com/topic/42877-problem-with-else-if/#findComment-208234 Share on other sites More sharing options...
HoTDaWg Posted March 15, 2007 Share Posted March 15, 2007 <?php include("classes/core.inc.php"); $obj = new core; session_start(); include_once("classes/core.inc.php"); //why are you including the same thing twice? meh if(session_is_registered('user')) { //this will automatically redirect the user, giving them the option to see something could be a security risk header(Location:http://www.domain.com/nos-potret/testcop-4.1.php?album=216&page=1); }else{ ?> Log in form <?php } ?> this should work. never mind stick with frosts THAT works. could somone please delete this post? thanks and sorry HoTDaWg Link to comment https://forums.phpfreaks.com/topic/42877-problem-with-else-if/#findComment-208237 Share on other sites More sharing options...
chanfuterboy Posted March 15, 2007 Author Share Posted March 15, 2007 hi, inserting <? include_once("classes/core.inc.php"); if(isset($_SESSION['user']) { print 'see it code here'; }else { print 'login code here'; } ?> it tell me that Parse error: syntax error, unexpected '{' in /home/george/public_html/betav2/new-site/rating/test-koi-pic.php on line 5 Link to comment https://forums.phpfreaks.com/topic/42877-problem-with-else-if/#findComment-208243 Share on other sites More sharing options...
per1os Posted March 15, 2007 Share Posted March 15, 2007 Need an extra ) on line 5 should be: if(isset($_SESSION['user'])) Link to comment https://forums.phpfreaks.com/topic/42877-problem-with-else-if/#findComment-208246 Share on other sites More sharing options...
chanfuterboy Posted March 15, 2007 Author Share Posted March 15, 2007 hi, inserting the other code <?php include("classes/core.inc.php"); $obj = new core; session_start(); include_once("classes/core.inc.php"); //why are you including the same thing twice? meh if(session_is_registered('user')) { //this will automatically redirect the user, giving them the option to see something could be a security risk header(Location:http://www.domain.com/nos-potret/testcop-4.1.php?album=216&page=1); }else{ ?> Log in form <?php } ?> I got Parse error: syntax error, unexpected ':' in /home/george/public_html/betav2/new-site/rating/test-koi-pic.php on line 10 Link to comment https://forums.phpfreaks.com/topic/42877-problem-with-else-if/#findComment-208248 Share on other sites More sharing options...
per1os Posted March 15, 2007 Share Posted March 15, 2007 Seriously if you cannot figure out how to locate simple parse errors you need to read up more on PHP. The problem is in the header(); you need " around the data inside IE: header("Location:etc...."); My suggestion learn PHP better before diving head deep into it, or even basic programming syntax structure. Link to comment https://forums.phpfreaks.com/topic/42877-problem-with-else-if/#findComment-208252 Share on other sites More sharing options...
chanfuterboy Posted March 15, 2007 Author Share Posted March 15, 2007 For frost it seems login and logout it keep write the same thing "login code here" what whould be the problem? Link to comment https://forums.phpfreaks.com/topic/42877-problem-with-else-if/#findComment-208254 Share on other sites More sharing options...
per1os Posted March 15, 2007 Share Posted March 15, 2007 Seriously, read my above post. you did not set $_SESSION['user'] to anything. Read how to code PHP first before diving head first into it man. You cannot get anywhere without reading. So read, php.net is a great reasource. Link to comment https://forums.phpfreaks.com/topic/42877-problem-with-else-if/#findComment-208257 Share on other sites More sharing options...
chanfuterboy Posted March 15, 2007 Author Share Posted March 15, 2007 Hi, i have idea but i dont know how to do it small. I try and i comeup whit a long script that work, but how can i make it small as the first post that i send <? include("classes/core.inc.php"); $obj = new core; session_start(); include_once("classes/core.inc.php"); ?> <? if($_POST['login'] == 1 && !session_is_registered('user')) { $SQL = "select * from user where Email='".$_POST['Email']."' and Password ='".$_POST['auth']."' and active=1"; $obj->execute_query($SQL); if($obj->record_count() > 0) { $result = $obj->get_rows(); $_SESSION['user'] = $result[0]['UserId']; $backURL=($_REQUEST['backURL'] <> '') ? $_REQUEST['backURL'] : "page1.php"; $backURL=str_replace("~","&",$backURL); header("location:".$backURL); } } ?> <? if(!session_is_registered('user')) { ?> <a href="jhj.oo">login</a> <? } else { $SQL = "select UserName AS name,user.UserId,MediaId from user,usermedia where user.active='1' and user.UserId =usermedia.UserId and usermedia.MainMedia = '1' and user.UserId=".$_SESSION['user']; $obj->execute_query($SQL); if($obj->record_count() > 0) { $regresult = $obj->get_one_row(); $name = $regresult[name]; ?> <div align="center"> You are loged in as:<font size="3"><br></font><b><font size="3"><?=$name;?></font></b> <br><br> <a href="http://www.domain.com/betav2/new-site/rating/login.php?logout=logout&id="><img border="0" src="http://www.awortinkos.com/betav_backup/betav/new-site/rating/images/logoutb.gif" width="61" height="24"></a> </div> <? } } ?> Link to comment https://forums.phpfreaks.com/topic/42877-problem-with-else-if/#findComment-208268 Share on other sites More sharing options...
per1os Posted March 15, 2007 Share Posted March 15, 2007 Dude, use [ code ] [ /code ]. Seriously, especially with HTML output which this form automatically displays. Link to comment https://forums.phpfreaks.com/topic/42877-problem-with-else-if/#findComment-208270 Share on other sites More sharing options...
chanfuterboy Posted March 15, 2007 Author Share Posted March 15, 2007 Hi, i have idea but i dont know how to do it small. I try and i comeup whit a long script that work, but how can i make it small as the first post that i send <? include("classes/core.inc.php"); $obj = new core; session_start(); include_once("classes/core.inc.php"); ?> <? if($_POST['login'] == 1 && !session_is_registered('user')) { $SQL = "select * from user where Email='".$_POST['Email']."' and Password ='".$_POST['auth']."' and active=1"; $obj->execute_query($SQL); if($obj->record_count() > 0) { $result = $obj->get_rows(); $_SESSION['user'] = $result[0]['UserId']; $backURL=($_REQUEST['backURL'] <> '') ? $_REQUEST['backURL'] : "page1.php"; $backURL=str_replace("~","&",$backURL); header("location:".$backURL); } } ?> <? if(!session_is_registered('user')) { ?> <a href="jhj.oo">login</a> <? } else { $SQL = "select UserName AS name,user.UserId,MediaId from user,usermedia where user.active='1' and user.UserId =usermedia.UserId and usermedia.MainMedia = '1' and user.UserId=".$_SESSION['user']; $obj->execute_query($SQL); if($obj->record_count() > 0) { $regresult = $obj->get_one_row(); $name = $regresult[name]; ?> <div align="center"> You are loged in as:<font size="3"><br></font><b><font size="3"><?=$name;?></font></b> <br><br> <a href="http://www.domain.com/betav2/new-site/rating/login.php?logout=logout&id="><img border="0" src="http://www.awortinkos.com/betav_backup/betav/new-site/rating/images/logoutb.gif" width="61" height="24"></a> </div> <? } } ?> Link to comment https://forums.phpfreaks.com/topic/42877-problem-with-else-if/#findComment-208273 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.