supanoob Posted April 2, 2006 Share Posted April 2, 2006 this is what i have as my login form the one that shows onc you have logged in etc[code]<?phpsession_start();//this code is compyright to supanoob http://www.twottk.com// to use this code you must have his permission to gain// permission please mail him at webmaster@twottk.comrequire_once('header.php');if (!$_POST['user'] || !$_POST['password']){include_once('index.php');die ('cannot find you in database');}$email=$_POST['user'];$password=$_POST['password'];$query="select playerid, user, email, fatigue, maxfat, power, speed, dex, intel, health, maxhealth from players where user='$user' and password='$password'";$result=mysql_query($query);if (!$result){die (mysql_error());}$num_rows=mysql_num_rows($result);if ($num_rows > 0){$_session['playerid'] = $playerid;$_session['user'] = $user;}?><?phpif ($num_rows < 1){ die ('Could not find you in the database');}?><HTML><HEAD><style type="text/css" media="all"> @import "css.php"; </style> <TITLE>TWOTTK.COM</TITLE></HEAD><TABLE width=100% border=0 cellpadding=0 cellspacing=0><TR> <TD colspan=5> <p align="center"> <img src="http://www.twottk.com/game/banner.jpg" width="730" height="160"></p> <TABLE border=0 cellpadding=0 cellspacing=0> <TR><TD> </TD></TR> </TABLE> </TD></TR><TR height=20><TD colspan=5 align=left><!-- SPACER --></TD></TR><TR> <TD align=left width=5><!-- SPACER --></TD> <TD align=left WIDTH=20% valign=top> <TABLE border=0 cellpadding=0 cellspacing=0 height="85" width="164"> <TR> <TD colspan=2 width=164 height="17"><hr></TD> </TR> <TR> <?phprequire_once('cssloggedin.php');$row=mysql_fetch_array($result);{$playerid=($row['playerid']);$user=($row['user']);$fatigue=($row['fatigue']);$maxfat=($row['maxfat']);$power=($row['power']);$speed=($row['speed']);$dex=($row['dex']);$intel=($row['intel']);$health=($row['health']);$maxhealth=($row['maxhealth']);$_session['playerid'] = $playerid;$_session['user'] = $user;?> <TR> <TD colspan=2 width=164 height="30"> Game Stats:<br> Health: <?php echo "$health / $maxhealth" ?><br> Fatigue: <?php echo "$fatigue / $maxfat" ?><hr> <p><hr>Navigation:<br> Home<br>Town<br> Logout<br> <hr></p> <hr></TD> </TR> <TR height=20> <TD height="1" width="164"><!-SPACER-></TD> </TR> <TR> <TD colspan=2 width=164 height="1"> </TD> </TR> <TR> <TD width=164 bgcolor=#FFFFFF valign=top height="12"><samp>Logged In: <?php echo date ('jS F'); ?><p></samp></TD> <TD width=1 bgcolor=#FFFFFF height="12"></TD> </TR> <TR> <TD colspan=2 width=164 height="12"><hr> </TD> </TR> </TABLE> <BR> </TD> <TD align=left width=1%><!-- SPACER --></TD> <TD align=left WIDTH=78% valign=top> <TABLE width=744 border=0 cellpadding=0 cellspacing=0 height="12"> <TR> <TD valign=top align=left width=4 height="12"></TD> <TD valign=top align=center background=templates/default/images/menuback.gif width="736" height="12"><hr></TD> <TD valign=top align=right width=4 height="12"></TD> </TR> </TABLE><TABLE width=740 border=0 cellpadding=0 cellspacing=0> <TR> <TD width=1 bgcolor=#FFFFFF></TD> <TD bgcolor=#FFFFFF width="733" > <p align="center"> <img src="http://www.twottk.com/game/character.jpg" width="105" height="200"></p> <div id="gamestats"> <?phpecho "<b>Character Stats:</b><br /><br />Power: $power <br /> Speed: $speed <br /> Dexterity: $dex <br /> Inteligence: $intel"; }?></div> <p> </p> <p> </p> <p> </p> <p> </p> <p> </TD> </TR> </TABLE> <p> </p> <TABLE width=748 border=0 cellpadding=0 cellspacing=0 height="39"> <TR> <TD valign=top align=left width=4 height="39"> </TD> <TD align=center background=templates/default/images/menu_bottom.gif width="740" height="39"><hr></TD> <TD valign=top align=right width=4 height="39"> </TD> </TR> </TABLE> <br><CENTER> <p></p> </CENTER> </TD> <TD align=left width=10><!-- SPACER --></TD></TR></TABLE></BODY></HTML>[/code]and this is what i have a my town.php[code]<?phpsession_start();require_once('header.php');if ($_SESSION['playerid']);{?><HEAD> <TITLE>TWOTTK.COM</TITLE></HEAD><TABLE width=100% border=0 cellpadding=0 cellspacing=0><TR> <TD colspan=5> <p align="center"> </p> <TABLE border=0 cellpadding=0 cellspacing=0> <TR><TD> </TD></TR> </TABLE> </TD></TR><TR height=20><TD colspan=5 align=left><!-- SPACER --></TD></TR><TR> <TD align=left width=5><!-- SPACER --></TD> <TD align=left WIDTH=20% valign=top> <TABLE border=0 cellpadding=0 cellspacing=0 height="85" width="164"> <TR> <TD colspan=2 width=164 height="17"><hr></TD> </TR> <TR> <TR> <TD colspan=2 width=164 height="30">require_once('cssloggedin.php');$_session['playerid'] = $playerid;$_session['user'] = $user;?> <hr> <p><hr> <hr></p> <hr></TD> </TR> <TR height=20> <TD height="1" width="164"><!-SPACER-></TD> </TR> <TR> <TD colspan=2 width=164 height="1"> </TD> </TR> <TR> <TD width=164 bgcolor=#FFFFFF valign=top height="12"> <p> </TD> <TD width=1 bgcolor=#FFFFFF height="12"></TD> </TR> <TR> <TD colspan=2 width=164 height="12"><hr> </TD> </TR> </TABLE> <BR> </TD> <TD align=left width=1%><!-- SPACER --></TD> <TD align=left WIDTH=78% valign=top> <TABLE width=744 border=0 cellpadding=0 cellspacing=0 height="12"> <TR> <TD valign=top align=left width=4 height="12"></TD> <TD valign=top align=center background=templates/default/images/menuback.gif width="736" height="12"><hr></TD> <TD valign=top align=right width=4 height="12"></TD> </TR> </TABLE><TABLE width=740 border=0 cellpadding=0 cellspacing=0> <TR> <TD width=1 bgcolor=#FFFFFF></TD> <TD bgcolor=#FFFFFF width="733" > <p> This is where the town will be displayed</p> <div id="gamestats"></div> <p> </p> <p> </p> <p> </p> <p> </p> <p> </TD> </TR> </TABLE> <p> </p> <TABLE width=748 border=0 cellpadding=0 cellspacing=0 height="39"> <TR> <TD valign=top align=left width=4 height="39"> </TD> <TD align=center background=templates/default/images/menu_bottom.gif width="740" height="39"><hr></TD> <TD valign=top align=right width=4 height="39"> </TD> </TR> </TABLE> <br><CENTER> <p></p> </CENTER> </TD> <TD align=left width=10><!-- SPACER --></TD></TR></TABLE></BODY></HTML><?php{echo "you are not logged in"?>// You may want to use SID here, like we did in page1.phpecho '<br /><a href="login3.php">page 1</a>';?> [/code]now the problem is when i go to town and click the link back it doesnt work, also you can view the town even when not logged in :( although when i click the back to page one link (testing one) it takes me back to the login page. never back to the character page. Quote Link to comment Share on other sites More sharing options...
toplay Posted April 2, 2006 Share Posted April 2, 2006 Change all occurrences of $_session to $_SESSION. Quote Link to comment Share on other sites More sharing options...
supanoob Posted April 3, 2006 Author Share Posted April 3, 2006 ahh right ok thank, i thought that would of come up with an error :Sthat didnt work, it still does the same thing Quote Link to comment Share on other sites More sharing options...
toplay Posted April 3, 2006 Share Posted April 3, 2006 Read my session troubleshooting post in the FAQ page pinned at the top of the newbie topic area.Read some session tutorials check your php.ini settings and try a simple test script (like provided in the FAQ Page).When reporting back, please be as specific as you can of what's going on, provide a URL to the site, and not just post it's not working.:) Quote Link to comment Share on other sites More sharing options...
supanoob Posted April 3, 2006 Author Share Posted April 3, 2006 well i mailed you with a link etc hope you can help i been looking over the same bit of code for hours at a time :S 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.