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> <? } ?> Quote Link to comment 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. Quote Link to comment 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 Quote Link to comment 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 Quote Link to comment 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'])) Quote Link to comment 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 Quote Link to comment 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. Quote Link to comment 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? Quote Link to comment 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. Quote Link to comment 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> <? } } ?> Quote Link to comment 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. Quote Link to comment 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> <? } } ?> 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.