Page 9 of 35

Re: Video#5

Posted: Tue Dec 22, 2009 4:57 am
by hallsofvallhalla
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

Posted: Tue Dec 22, 2009 12:31 pm
by thuron
once I added this login thing, I got problems with my attack page. when I attack I see this:
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
line 6:

Code: Select all

$playerinfo="SELECT * from players where name='$player'";
I already tryed putting this above it:

Code: Select all

$creature=$_GET['player'];
and some other variations of that, but it wont work. how do I get this working so I see the playername up there?

Re: Video#5

Posted: Tue Dec 22, 2009 3:24 pm
by hallsofvallhalla
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

Posted: Tue Dec 22, 2009 3:27 pm
by thuron
i just figured it out: i forgot this above my page:

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;
}
thanks anyways

Re: Video#5

Posted: Tue Dec 22, 2009 7:35 pm
by GrInd3r
shouldn't the $creature= $_GET['player'] should be $creature = $playerinfo3['creature'] unless you are doing something on the lines of PVP??

Re: Video#5

Posted: Wed Dec 30, 2009 10:40 pm
by rangersko
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?

Re: Video#5

Posted: Thu Dec 31, 2009 12:10 am
by hallsofvallhalla

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);
should be

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

Posted: Thu Dec 31, 2009 12:15 am
by rangersko
right i changed that too but it say when i log in (not logged in) :(

Re: Video#5

Posted: Thu Dec 31, 2009 2:30 pm
by hallsofvallhalla
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.

Re: Video#5

Posted: Tue Jan 05, 2010 7:44 pm
by zolacat999
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