Browser MMO Video #9
- hallsofvallhalla
- Site Admin
- Posts: 12023
- Joined: Wed Apr 22, 2009 11:29 pm
Re: Video #9
sounds like a DB issue. no caps or anything?
Re: Video #9
maybe you made "e-mail" instead of "email" i did that first.
Re: Video #9
has to beZerk wrote:At this point all I get is "could not register"
I realize this comes from the following line:but I can't figure out what I have wrong. I've checked my data base for correctness (looks same as halls') many times. If there is nothing wrong with this script, why will it not register?Code: Select all
$SQL = "INSERT into player(name, password, email, level, exper, attack, defense, hpoints, maxhp, spoints, maxspoints) VALUES ('$player','$password','$email','1','0','$classquery3[attack]','$classquery3[defense]','$classquery3[hpoints]','$classquery3[hpoints]','$classquery3[spoints]','$classquery3[spoints]')"; mysql_query($SQL) or die("could not register");
Code: Select all
$SQL = "INSERT into [u]players[/u](name, password, email, level, exper, attack, defense, hpoints, maxhp, spoints, maxspoints) VALUES ('$player','$password','$email','1','0','$classquery3[attack]','$classquery3[defense]','$classquery3[hpoints]','$classquery3[hpoints]','$classquery3[spoints]','$classquery3[spoints]')";
mysql_query($SQL) or die("could not register");
Re: Video #9
hey, when i try logging into my game, after 9b or something
i have to use the 32 length password and i cant use the one i made when i registered
when i try logging in without my 32 length password or something like that, it says "Wrong Username or Password" Go Back
here is my login.php code:
here is my authenticate.php code:
here is my reguser.php:
<?php
include 'connect.php';
?>
<?php
$player=$_POST['player'];
$password=$_POST['password'];
$pass2=$_POST['pass2'];
$player=strip_tags($player);
$email=$_POST['email'];
$email=strip_tags($email);
$classchoice=$_POST['classchoice'];
if ($email == "")
{
echo "You didn't enter a email address!<br>";
echo " <A href='register.php'>Go back</a>";
exit;
}
if ($password==$pass2)
{
$isplayer="SELECT * from players where name='$player'";
$isplayer2=mysql_query($isplayer) or die("Could not query players table");
$isplayer3=mysql_fetch_array($isplayer2);
if(!$_POST['password'] || !$_POST['pass2'])
{
print "You did not enter a password<br>";
echo " <A href='register.php'>Go back</a>";
exit;
}
else if($isplayer3 || strlen($player)>21 || strlen($player)<1)
{
print "There is already a player of that name or the name you specified is over 16 letters or less than 1 letter";
echo " <A href='register.php'>Go back</a><br>";
exit;
}
else
{
$isaddress="SELECT * from players where email='$email'";
$isaddress2=mysql_query($isaddress) or die("not able to query for password");
$isaddress3=mysql_fetch_array($isaddress2);
if($isaddress3)
{
print "There is already a player with that e-mail address";
echo " <A href='register.php'>Go back</a><br>";
exit;
}
else
{
$password=md5($password);
//////////////////////////////new for video 9//////////////
$classquery="SELECT * from classes where name='$classchoice'";
$classquery2=mysql_query($classquery) or die("Could not query classes");
$classquery3=mysql_fetch_array($classquery2);
$SQL = "INSERT into players(name, password, email, level, exper, attack, defense, hpoints, maxhp, spoints, maxspoints) VALUES ('$player','$password','$email','1','0','$classquery3[attack]','$classquery3[defense]','$classquery3[hpoints]','$classquery3[hpoints]','$classquery3[spoints]','$classquery3[spoints]')";
mysql_query($SQL) or die("could not register");
print "Thank you for registering!";
}
}
}
else
{
print "Your password didn't match or you did not enter a password";
echo " <A href='register.php'>Go back</a><br>";
exit;
}
echo " <A href='login.php'>Login Page</a><br>";
?>
and register.php
<?php
include 'connect.php';
?>
<form method ="post" action="reguser.php">
Type Username Here: <input type="text" name="player" size="21"><br>
Type Password Here: <input type="text" name="password" size "15"><br>
ReType Password Again: <input type="text" name="pass2" size "15"><br>
Type Email Address: <input type="text" name="email" size "60"><br>
<input type="submit" value="submit">
<?php
print "<select name='classchoice' length='20'>";
$classinfo="SELECT * from classes";
$classinfo2=mysql_query($classinfo) or die("Could not select classes");
while ($classinfo3=mysql_fetch_array($classinfo2))
{
print "<option>$classinfo3[name]</option>";
}
print "</select><br>";
?>
</form>
<?php
print "<center><h3>Class Starting modifiers</h3></center>";
print "<center>";
print "<table border='0' width='70%' cellspacing='20'>";
print "<tr><td width='25%' valign='top'>";
print "</td>";
print "<td valign='top' width='75%'>";
$selectclass="SELECT * from classes";
$selectclass2=mysql_query($selectclass) or die("could not select Classes");
print "<table border='1' bordercolor='black' bgcolor='#ffffff'>";
print "<tr><td><font color='cc0033'>Class<font color='ffffff'>_____________</td><td><font color='cc0033'>Attack<font color='ffffff'>_</font><td><font color='cc0033'>Defense<font color='ffffff'>_</font></td><td><font color='cc0033'>Hit Points<font color='ffffff'>_</font></td><td><font color='cc0033'>Spell Points<font color='ffffff'>_</font></td></tr>";
while($selectclass3=mysql_fetch_array($selectclass2))
{
print "<tr><td>$selectclass3[name]</td><td>$selectclass3[attack]</td><td>$selectclass3[defense]</td><td>$selectclass3[hpoints]</td><td>$selectclass3[spoints]</td></tr>";
}
print "</table>";
print "</td></tr></table>";
print "</center>";
?>
if you guys could help, thank you very much! also, when i do get logged in, (useing length 32 pass) i add stuff to the store, and when im logged in, theres nothing...
so thanks if you help
store.php code:
buyitem.php
PLEASE HELP! THANKS
i have to use the 32 length password and i cant use the one i made when i registered
when i try logging in without my 32 length password or something like that, it says "Wrong Username or Password" Go Back
here is my login.php code:
Code: Select all
<form method="POST" action="authenticate.php">
User Name <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">
<br><br>Not Registered? <a href='register.php'>Register
Code: Select all
<?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'";
$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='index.php'>Continue</a></big>";
}
else
{
echo "<big>Wrong username or password.<A href='login.php'>Try Again</a></big>";
}
}
?>
<?php
include 'connect.php';
?>
<?php
$player=$_POST['player'];
$password=$_POST['password'];
$pass2=$_POST['pass2'];
$player=strip_tags($player);
$email=$_POST['email'];
$email=strip_tags($email);
$classchoice=$_POST['classchoice'];
if ($email == "")
{
echo "You didn't enter a email address!<br>";
echo " <A href='register.php'>Go back</a>";
exit;
}
if ($password==$pass2)
{
$isplayer="SELECT * from players where name='$player'";
$isplayer2=mysql_query($isplayer) or die("Could not query players table");
$isplayer3=mysql_fetch_array($isplayer2);
if(!$_POST['password'] || !$_POST['pass2'])
{
print "You did not enter a password<br>";
echo " <A href='register.php'>Go back</a>";
exit;
}
else if($isplayer3 || strlen($player)>21 || strlen($player)<1)
{
print "There is already a player of that name or the name you specified is over 16 letters or less than 1 letter";
echo " <A href='register.php'>Go back</a><br>";
exit;
}
else
{
$isaddress="SELECT * from players where email='$email'";
$isaddress2=mysql_query($isaddress) or die("not able to query for password");
$isaddress3=mysql_fetch_array($isaddress2);
if($isaddress3)
{
print "There is already a player with that e-mail address";
echo " <A href='register.php'>Go back</a><br>";
exit;
}
else
{
$password=md5($password);
//////////////////////////////new for video 9//////////////
$classquery="SELECT * from classes where name='$classchoice'";
$classquery2=mysql_query($classquery) or die("Could not query classes");
$classquery3=mysql_fetch_array($classquery2);
$SQL = "INSERT into players(name, password, email, level, exper, attack, defense, hpoints, maxhp, spoints, maxspoints) VALUES ('$player','$password','$email','1','0','$classquery3[attack]','$classquery3[defense]','$classquery3[hpoints]','$classquery3[hpoints]','$classquery3[spoints]','$classquery3[spoints]')";
mysql_query($SQL) or die("could not register");
print "Thank you for registering!";
}
}
}
else
{
print "Your password didn't match or you did not enter a password";
echo " <A href='register.php'>Go back</a><br>";
exit;
}
echo " <A href='login.php'>Login Page</a><br>";
?>
and register.php
<?php
include 'connect.php';
?>
<form method ="post" action="reguser.php">
Type Username Here: <input type="text" name="player" size="21"><br>
Type Password Here: <input type="text" name="password" size "15"><br>
ReType Password Again: <input type="text" name="pass2" size "15"><br>
Type Email Address: <input type="text" name="email" size "60"><br>
<input type="submit" value="submit">
<?php
print "<select name='classchoice' length='20'>";
$classinfo="SELECT * from classes";
$classinfo2=mysql_query($classinfo) or die("Could not select classes");
while ($classinfo3=mysql_fetch_array($classinfo2))
{
print "<option>$classinfo3[name]</option>";
}
print "</select><br>";
?>
</form>
<?php
print "<center><h3>Class Starting modifiers</h3></center>";
print "<center>";
print "<table border='0' width='70%' cellspacing='20'>";
print "<tr><td width='25%' valign='top'>";
print "</td>";
print "<td valign='top' width='75%'>";
$selectclass="SELECT * from classes";
$selectclass2=mysql_query($selectclass) or die("could not select Classes");
print "<table border='1' bordercolor='black' bgcolor='#ffffff'>";
print "<tr><td><font color='cc0033'>Class<font color='ffffff'>_____________</td><td><font color='cc0033'>Attack<font color='ffffff'>_</font><td><font color='cc0033'>Defense<font color='ffffff'>_</font></td><td><font color='cc0033'>Hit Points<font color='ffffff'>_</font></td><td><font color='cc0033'>Spell Points<font color='ffffff'>_</font></td></tr>";
while($selectclass3=mysql_fetch_array($selectclass2))
{
print "<tr><td>$selectclass3[name]</td><td>$selectclass3[attack]</td><td>$selectclass3[defense]</td><td>$selectclass3[hpoints]</td><td>$selectclass3[spoints]</td></tr>";
}
print "</table>";
print "</td></tr></table>";
print "</center>";
?>
if you guys could help, thank you very much! also, when i do get logged in, (useing length 32 pass) i add stuff to the store, and when im logged in, theres nothing...
so thanks if you help
store.php code:
Code: Select all
<?php
include_once 'connect.php';
session_start();
if (isset($_SESSION['player']))
{
$player=$_SESSION['player'];
}
else
{
echo "Not Logged in <br><br> <A href='login.php'>Login</a>";
exit;
}
$counter = 0;
$playerinfo="SELECT * from players where name='$player'";
$playerinfo2=mysql_query($playerinfo) or die("could not get player stats!");
$playerinfo3=mysql_fetch_array($playerinfo2);
echo "<small>";
print "<center>";
print "<table border='0' width='70%' cellspacing='20'>";
print "<tr><td width='25%' valign='top'>";
print "</td>";
print "<td valign='top' width='75%'>";
$invinfo="SELECT * from store where amount > 0";
$invinfo2=mysql_query($invinfo) or die("could not select anything from the store.");
print "<table border='1' bordercolor='white' bgcolor='#ffffff'>";
print "<tr><td>Name<font color='ffffff'>________________</td><td>Stat<font color='ffffff'>______</td><td>Stat Add<font color='ffffff'>______</td><td>Type<font color='ffffff'>______</td><td>Price<font color='ffffff'>______</td></tr>";
while($invinfo3=mysql_fetch_array($invinfo2))
{
$counter = 1;
print "<tr><td>$invinfo3[name]</td><td>$invinfo3[stats]</td><td>$invinfo3[statadd]</td><td>$invinfo3[type]</td><td>$invinfo3[price]</td><td><A href='buyitem.php?randid=$invinfo3[randid]'>Buy Item</td></tr>";
}
print "</table>";
print "</td></tr></table>";
print "</center>";
echo "</small>";
if ($counter == 0)
{
echo "<center>There is nothing in the store at this time.<br>";
echo "<a href='index.php'>Go Back</center>";
exit;
}
echo "<center><a href='index.php'>NeverMind</center>";
?>
Code: Select all
<?php
include_once 'connect.php';
session_start();
if (isset($_SESSION['player']))
{
$player=$_SESSION['player'];
}
else
{
echo "Not Logged in <br><br> <A href='login.php'>Login</a>";
exit;
}
$randid=$_GET['randid'];
$playerinfo="SELECT * from players where name='$player'";
$playerinfo2=mysql_query($playerinfo) or die("could not get player stats!");
$playerinfo3=mysql_fetch_array($playerinfo2);
$playerid = $playerinfo3['id'];
$iteminfo="SELECT * from store where randid='$randid'";
$iteminfo2=mysql_query($iteminfo) or die("could not get item stats!");
$iteminfo3=mysql_fetch_array($iteminfo2);
$name = $iteminfo3['name'];
$stats = $iteminfo3['stats'];
$statadd = $iteminfo3['statadd'];
$type = $iteminfo3['type'];
$randid2 = rand(1000,999999999);
$itembought = "INSERT into inventory(id, name, stats, statadd, randid,type) VALUES ('$playerid','$name','$stats','$statadd','$randid2','$type')";
mysql_query($itembought) or die("could not insert item into backpack");
echo $name . " Purchased";
echo "<center><a href='index.php'>Go Back</center>";
////did not make a - counter for item////
?>
PLEASE HELP! THANKS
- Jackolantern
- Posts: 10891
- Joined: Wed Jul 01, 2009 11:00 pm
Re: Video #9
So you are actually having to login by typing your 32-character MD5'd password? That is strange. I read it and thought "This is easy, he isn't MD5'ing the password on the authenticate script", but that obviously isn't the case. I will need more time to look at this, but maybe someone else will figure it out first
The indelible lord of tl;dr
Re: Video #9
ok, thanks
i will wait for some more people
i will wait for some more people
Re: Video #9
in authenticate.php, change:
$query = "select name,password from players where name='$player' and '$password'";
to:
$query = "select name,password from players where name='$player' and password='$password'";
and see if that makes a difference
$query = "select name,password from players where name='$player' and '$password'";
to:
$query = "select name,password from players where name='$player' and password='$password'";
and see if that makes a difference
Re: Video #9
With the store issue
Have you created different location? The item can be in one store and not another.
Have you set up levels with you items? Make sure your character is correct level for the item. Make sure that your spelling is the same on all your items, pages, scripts, data bases, and make sure that you check your capitalazation is the same. I put everything in lower case until i get the script to work and then change 1 thing at a time until I know it works. Remember that "Warrior" is not the same as "warrior" in programing. I found that most of my problems were in my data bases and not the script.
Hope this helps
Have you created different location? The item can be in one store and not another.
Have you set up levels with you items? Make sure your character is correct level for the item. Make sure that your spelling is the same on all your items, pages, scripts, data bases, and make sure that you check your capitalazation is the same. I put everything in lower case until i get the script to work and then change 1 thing at a time until I know it works. Remember that "Warrior" is not the same as "warrior" in programing. I found that most of my problems were in my data bases and not the script.
Hope this helps
Re: Video #9
thanks oldrod and thanks kirbie!
- Jackolantern
- Posts: 10891
- Joined: Wed Jul 01, 2009 11:00 pm
Re: Video #9
That is a pretty good error check list thereKirbie wrote:With the store issue
Have you created different location? The item can be in one store and not another.
Have you set up levels with you items? Make sure your character is correct level for the item. Make sure that your spelling is the same on all your items, pages, scripts, data bases, and make sure that you check your capitalazation is the same. I put everything in lower case until i get the script to work and then change 1 thing at a time until I know it works. Remember that "Warrior" is not the same as "warrior" in programing. I found that most of my problems were in my data bases and not the script.
Hope this helps
The indelible lord of tl;dr