[youtubehd]http://www.youtube.com/watch?v=aqjetYOUXT8[/youtubehd]
video 9b
[youtubehd]http://www.youtube.com/watch?v=ZfYA2okQCiU[/youtubehd]
register.php
Code: Select all
<?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>";
?>
reguser.php
Code: Select all
<?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>";
?>
login.php
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
index.php
Code: Select all
<?php
include_once 'connect.php';
session_start();
include_once 'logo.php';
?>
<link href="style.css" rel="stylesheet" type="text/css" />
<div id="login2" div align="center">
<?php
if (isset($_SESSION['player']))
{
$player=$_SESSION['player'];
}
else
{
echo "Not Logged in <br><br> <A href='login.php'>Login</a>";
exit;
}
?>
</div>
<div id ="locations">
<?php
$playerinfo="SELECT * from players where name='$player'";
$playerinfo2=mysql_query($playerinfo) or die("could not get player stats!");
$playerinfo3=mysql_fetch_array($playerinfo2);
$playerhp = $playerinfo3['hpoints'];
if ($playerhp < 1)
{
echo "You are dead!" ;
echo "<br><a href='useitem.php>Use an Item";
exit;
}
echo "<b><big><u>Locations</u></big></b><br>";
echo "<a href='store.php'>Visit Store<br>";
echo "<a href='battle.php'>Battle in Arena<br>";
?>
</div>
<div id="logout">
<?php
echo "<br><a href='logout.php'><img src='images/logout.gif'>";
?>
</div>
style.css
Code: Select all
body {
background-color: #ffffff;
}
#login {
position:absolute;
left:0px;
top:0px;
width:800px;
height:150px;
z-index:1;
}
#login2 {
position:absolute;
left:0px;
top:200px;
width:800px;
height:150px;
z-index:1;
}
#player {
position:absolute;
left:400px;
top:200px;
width:450px;
height:450px;
z-index:3;
}
#creature {
position:absolute;
left:400px;
top:400px;
width:450px;
height:450px;
z-index:3;
}
#logout {
position:absolute;
left:10px;
top:10px;
width:150px;
height:150px;
z-index:3;
}
#locations {
position:absolute;
left:400px;
top:100px;
width:450px;
height:450px;
z-index:3;
}
authenticate.php
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>";
}
}
?>
battle.php
Code: Select all
<?php
include_once 'connect.php';
session_start();
include_once 'logo.php';
?>
<link href="style.css" rel="stylesheet" type="text/css" />
<div id="login2" div align="center">
<?php
if (isset($_SESSION['player']))
{
$player=$_SESSION['player'];
}
else
{
echo "Not Logged in <br><br> <A href='login.php'>Login</a>";
exit;
}
?>
</div>
<?php
$playerinfo="SELECT * from players where name='$player'";
$playerinfo2=mysql_query($playerinfo) or die("could not get player stats!");
$playerinfo3=mysql_fetch_array($playerinfo2);
$playerhp = $playerinfo3['hpoints'];
$playerattack = $playerinfo3['attack'];
$playerdefense = $playerinfo3['defense'];
////////////////new for video 7///////////////
if (isset($_GET['randid']))
{
$randid=$_GET['randid'];
$iteminfo="SELECT * from inventory where randid='$randid'";
$iteminfo2=mysql_query($iteminfo) or die("could not get item stats!");
$iteminfo3=mysql_fetch_array($iteminfo2);
if (!$iteminfo3['name'])
{
}
else
{
$name = $iteminfo3['name'];
$stats = $iteminfo3['stats'];
$statadd = $iteminfo3['statadd'];
$type = $iteminfo3['type'];
if ($type == "healing")
{
$newhp = $statadd + $playerhp;
if ($newhp > $playerinfo3['maxhp'])
{
$newhp = $playerinfo3['maxhp'];
}
$updateplayer="update players set hpoints='$newhp' where name='$player'";
mysql_query($updateplayer) or die("Could not update player");
$updateitem="DELETE from inventory where name='$name' AND randid='$randid' limit 1";
mysql_query($updateitem) or die("Could not delete item");
$playerhp = $newhp;
echo "Used " . $name . " and recovered " . $statadd . ".<br>";
}
}}
////////////////////////////////
if (isset($_GET['creature']))
{
$creature=$_GET['creature'];
$creatureinfo="SELECT * from creatures where name = '$creature'";
$creatureinfo2=mysql_query($creatureinfo) or die("could not get the creature you were fighting!");
$creatureinfo3=mysql_fetch_array($creatureinfo2);
}
else
{
$creatureinfo="SELECT * from creatures order by rand() limit 1";
$creatureinfo2=mysql_query($creatureinfo) or die("could get a creature!");
$creatureinfo3=mysql_fetch_array($creatureinfo2);
}
$creature = $creatureinfo3['name'];
$creaturehp = $creatureinfo3['hpoints'];
$creatureattack = $creatureinfo3['attack'];
$creaturedefense = $creatureinfo3['defense'];
?>
<div id="player">
<?php
/////player info
echo "<u> " . $playerinfo3['name'] . "</u><br>";
echo "Hit points = " . $playerhp . "<br>";
echo "Attack = " . $playerattack . "<br>";
echo "Defense = " . $playerdefense . "<br><br><br>";
?>
</div>
<div id="creature">
<?php
///////creature info
echo "<u> " . $creatureinfo3['name'] . "</u><br>";
echo "Hit points = " . $creaturehp . "<br>";
echo "Attack = " . $creatureattack . "<br>";
echo "Defense = " . $creaturedefense . "<br><br><br>";
echo "<a href='attack.php?creature=$creature'>Attack!";
echo "<br><a href='useitem.php?creature=$creature'>Use Item";
echo "<br><a href='index.php'>Exit Arena";
?>
</div>
<div id="logout">
<?php
echo "<br><a href='logout.php'><img src='images/logout.gif'>";
?>
</div>
store.php
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>";
?>
buyitem.php
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////
?>