Browser MMO Video #5
- hallsofvallhalla
- Site Admin
- Posts: 12026
- Joined: Wed Apr 22, 2009 11:29 pm
Re: Video#5
or just not worry about doing the videos until you get to video 18. Seems to work out better and you can import the database.
Re: Video#5
once I added this login thing, I got problems with my attack page. when I attack I see this:
I already tryed putting this above it:
and some other variations of that, but it wont work. how do I get this working so I see the playername up there?
line 6:Notice: Undefined variable: player in C:\Program Files\wamp\www\tutorial\attack.php on line 6
's Attack
's Attack roll is 8
goblin's defense roll is 8
misses!
goblin's Attack
goblin's Attack roll is 20
's defense roll is 1
goblin hits!
For 3 points of damage.
has been killed
Continue
Code: Select all
$playerinfo="SELECT * from players where name='$player'";
Code: Select all
$creature=$_GET['player'];
- hallsofvallhalla
- Site Admin
- Posts: 12026
- Joined: Wed Apr 22, 2009 11:29 pm
Re: Video#5
can we see more of your code? post all your code here. Also I recommend watching the videos up to about video 14 then building the code.
Re: Video#5
i just figured it out: i forgot this above my page:
thanks anyways
Code: Select all
session_start();
if (isset($_SESSION['player']))
{
$player=$_SESSION['player'];
}
else
{
echo "Not Logged in <br><br> <A href='login.php'>Login</a>";
exit;
}
Re: Video#5
shouldn't the $creature= $_GET['player'] should be $creature = $playerinfo3['creature'] unless you are doing something on the lines of PVP??
Re: Video#5
this is my code for authenticate:
<?php
session_start();
if (isset($_SESSION['player']))
{
$player=$_SESSION['player'];
}
else
{
echo "Not Logged in <br><br> <A href='login.php'>Login</a>";
exit;
}
if (isset($_POST['submit']))
{
$player=$_POST['player'];
$password=$_POST['password'];
$player=strip_tags($player);
$password=strip_tags($password);
$password=md5($password);
$query = "select name,password from players where name='$player' and '$password' ";
$result = mysql_query($query) or die ("Could not query players");
$result2 = mysql_fetch_array($result);
if ($result2)
{
$_SESSION['player']=$player;
echo "<big>Logged in successfully<br>";
echo "<A href='battle.php'>Continue</a></big>";
}
else
{
echo "<big>Wrong username or password. <A href='login.php'>Try Again</a></big>";
}
}
?>
then when i type my correct usename password it says not logged in. whys that?
<?php
session_start();
if (isset($_SESSION['player']))
{
$player=$_SESSION['player'];
}
else
{
echo "Not Logged in <br><br> <A href='login.php'>Login</a>";
exit;
}
if (isset($_POST['submit']))
{
$player=$_POST['player'];
$password=$_POST['password'];
$player=strip_tags($player);
$password=strip_tags($password);
$password=md5($password);
$query = "select name,password from players where name='$player' and '$password' ";
$result = mysql_query($query) or die ("Could not query players");
$result2 = mysql_fetch_array($result);
if ($result2)
{
$_SESSION['player']=$player;
echo "<big>Logged in successfully<br>";
echo "<A href='battle.php'>Continue</a></big>";
}
else
{
echo "<big>Wrong username or password. <A href='login.php'>Try Again</a></big>";
}
}
?>
then when i type my correct usename password it says not logged in. whys that?
- hallsofvallhalla
- Site Admin
- Posts: 12026
- Joined: Wed Apr 22, 2009 11:29 pm
Re: Video#5
Code: Select all
$query = "select name,password from players where name='$player' and '$password' ";
$result = mysql_query($query) or die ("Could not query players");
$result2 = mysql_fetch_array($result);
Code: Select all
$query = "select name,password from players where name='$player' and password='$password' ";
$result = mysql_query($query) or die ("Could not query players");
$result2 = mysql_fetch_array($result);
Re: Video#5
right i changed that too but it say when i log in (not logged in) 

- hallsofvallhalla
- Site Admin
- Posts: 12026
- Joined: Wed Apr 22, 2009 11:29 pm
Re: Video#5
sounds like it is not saving your session. E need to see the page that it says not logged in on. Like i said. You are better going through more videos first then using the source from the videos.
-
- Posts: 62
- Joined: Tue Nov 24, 2009 11:09 pm
Re: Video#5
right here we go im starting to make a bit of a track record for posting in every video thread lol. so here we go.
<form method="POST" action="authenticate.php">
UserName <input type="text" name="player" size="21"
Password <input type="password" name="password" size="21" mask="x">
<br>
<input type="submit" value="login" name="submit"
next problem is when I type in my name and password it just goes to a blank screen here is the code for authenticate.php
<?php
include_once 'connect.php';
session_start();
if (isset($_POST['submit']))
{
$player=$_POST['player'];
$password=$_POST['password'];
$player=strip_tags($player);
$password=strip_tags($password);
$password=md5($password);
$query = "select name,password from players where name='$player' and password='$password'";
$result = mysql_query($query) or die("Could not query players");
$result2 = mysql_fetch_array($result);
if ($result2)
{
$_SESSION['player']=$player;
echo "<big>Logged in successfully<br>";
echo "<A href='battle.php'>Continue</a></big>";
}
else
{
echo "<big>Wrong username or password.<A href='login.php'>Try Again</a></big>";
}
}
?>
lastly ill post a pic of my database
P.S hopefully the screenshots should upload in the correct order but not sure
<form method="POST" action="authenticate.php">
UserName <input type="text" name="player" size="21"
Password <input type="password" name="password" size="21" mask="x">
<br>
<input type="submit" value="login" name="submit"
next problem is when I type in my name and password it just goes to a blank screen here is the code for authenticate.php
<?php
include_once 'connect.php';
session_start();
if (isset($_POST['submit']))
{
$player=$_POST['player'];
$password=$_POST['password'];
$player=strip_tags($player);
$password=strip_tags($password);
$password=md5($password);
$query = "select name,password from players where name='$player' and password='$password'";
$result = mysql_query($query) or die("Could not query players");
$result2 = mysql_fetch_array($result);
if ($result2)
{
$_SESSION['player']=$player;
echo "<big>Logged in successfully<br>";
echo "<A href='battle.php'>Continue</a></big>";
}
else
{
echo "<big>Wrong username or password.<A href='login.php'>Try Again</a></big>";
}
}
?>
lastly ill post a pic of my database
P.S hopefully the screenshots should upload in the correct order but not sure