Page 1 of 1

Keeping a user logged in

Posted: Sun Oct 04, 2009 5:04 am
by Lordcyris
hello! i must say i find your tutorials very useful and what helped me out a lot was to read a php book before hand. Much like any language you need to practice before you can get the hang of it so thank you for your videos.

now to my request
I'm having a difficult time keeping my user logged in
i would like to change the player1 part in the code to reflect the user who is logged in in your attack.php code

Code: Select all

    $playerinfo="SELECT * from players where name='player1'";
    $playerinfo2=mysql_query($playerinfo) or die("could not get player stats!");
    $playerinfo3=mysql_fetch_array($playerinfo2);
once again thanks for time and efforts they are much appreciated

Re: Keeping a user logged in

Posted: Sun Oct 04, 2009 2:00 pm
by Lordcyris
sorry for double posting but i figured it out!!

Code: Select all

session_start();
$user = $_SESSION['name'];
include 'connect.php';
	



   $playerinfo="SELECT id,name,resource1,resource2,resource3 from players where name='$user'";
    $playerinfo2=mysql_query($playerinfo) or die("could not get player stats!");
    $playerinfo3=mysql_fetch_array($playerinfo2);

Re: Keeping a user logged in

Posted: Sun Oct 04, 2009 8:17 pm
by Falken
Great!

Move this thread to help/support mayby? :)

Re: Keeping a user logged in

Posted: Sun Oct 04, 2009 9:29 pm
by hallsofvallhalla
will do, glad you figured it out, nice work