Help
Re: Help
ok so i have hit a new problem
witch is iv got to video 3b and i made it all and it all right but when ever i try to test sing up it get this
so i puting my
username witch is = 7 letter long
then password = 6 letter long
and then my MSN witch is 18 letters and all i get is
Your password didn't match or you did not enter a password
and my passwords are the same
witch is iv got to video 3b and i made it all and it all right but when ever i try to test sing up it get this
so i puting my
username witch is = 7 letter long
then password = 6 letter long
and then my MSN witch is 18 letters and all i get is
Your password didn't match or you did not enter a password
and my passwords are the same
Re: Help
the codes are
and the next 1 is
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:<input type="text" name="pass2" size"15"><br>
Type E-mail address: <input type="text" name="email" size="60"><br>
<input type="submit" value="submit">
</form>
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);
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<br>";
echo " <A href='register.php'>Go back</a>";
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<br>";
echo " <A href='register.php'>Go back</a>";
exit;
}
else
{
$password=md5($password);
$SQL = "INSERT into players(name, password, email, level, exper) VALUES ('$player','$password','$email','1','0')";
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<br>";
echo " <A href='register.php'>Go back</a>";
exit;
}
echo "<br><A href='login.php'>Login Page</a>";
?>
- Lord Strife
- Posts: 104
- Joined: Wed Oct 28, 2009 3:10 pm
Re: Help
Code: Select all
$_POST['password']
Code: Select all
$_POST['Password'] (or change the <input> field to <input type="password" name="password"> in the <form>
Re: Help
ok i just mad my login page and stuff i followed your tut and when i login i it ses
Logged in Successfully
Continue
but when i click Continue i get
Not Logged in
Login
i dont no what i did wrong this is my battle code and attack code
Battle.php
Attack.php
Logged in Successfully
Continue
but when i click Continue i get
Not Logged in
Login
i dont no what i did wrong this is my battle code and attack code
Battle.php
Code: Select all
<?php
include_once 'connect.php';
session_start();
if (isset($_SESSTION['player']))
{
$player=$_SESSION['player'];
}
else
{
echo "Not Logged in <br><br> <A href='login.php'>Login</a>";
exit;
}
$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'];
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'];
/////player info
echo "<u> " . $playerinfo3['name'] . "</u><br>";
echo "Hit points = " . $playerhp . "<br>";
echo "Attack = " . $playerattack . "<br>";
echo "Defense = " . $playerdefense . "<br><br><br>";
///////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!";
?>
Attack.php
Code: Select all
<?php
include_once 'connect.php';
session_start();
if (isset($_SESSTION['player']))
{
$player=$_SESSION['player'];
}
else
{
echo "Not Logged in <br><br> <A href='login.php'>Login</a>";
exit;
}
$playerinfo="SELECT * from players where name='$player'";
$playerinfo2=mysql_query($playerinfo) or die("could not get player stats!");
$playerinfo3=mysql_fetch_array($playerinfo2);
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
{
echo "<a href='battle.php'>No Creature selected. Go Back!";
exit;
}
$playerhp = $playerinfo3['hpoints'];
$playerattack = $playerinfo3['attack'];
$playerdefense = $playerinfo3['defense'];
$creature = $creatureinfo3['name'];
$creaturehp = $creatureinfo3['hpoints'];
$creatureattack = $creatureinfo3['attack'];
$creaturedefense = $creatureinfo3['defense'];
///////////////////////players turn////////////////////
echo "<u> " . $playerinfo3['name'] . "'s Attack</u><br>";
$playerattack = rand(1,20) + $playerattack;
$creaturedefense = rand(1,20) + $creaturedefense;
echo $playerinfo3['name'] . "'s Attack roll is " . $playerattack . "<br>";
echo $creature . "'s defense roll is " . $creaturedefense. "<br>";
if ($playerattack > $creaturedefense)
{
echo $playerinfo3['name'] . " hits! <br>";
$playerdamage = rand(1,6);
$newcreaturehp = $creaturehp - $playerdamage;
echo "For " . $playerdamage . " points of damage. <br>";
if ($newcreaturehp < 1)
{
echo "The " . $creature . " has been killed";
$updatecreature="DELETE from creatures where name='$creature' limit 1";
mysql_query($updatecreature) or die("Could not update creature");
echo "<a href='battle.php'>Go Back";
exit;
}
$updatecreature="update creatures set hpoints='$newcreaturehp' where name='$creature' limit 1";
mysql_query($updatecreature) or die("Could not update creature");
}
else
{
echo $playerinfo3['name'] . " misses!<br>";
}
//////////////////////creatures turn //////////////////
echo "<u> " . $creature . "'s Attack</u><br>";
$creatureattack = rand(1,20) + $creatureattack;
$playerdefense = rand(1,20) + $playerdefense;
echo $creature . "'s Attack roll is " . $creatureattack . "<br>";
echo $playerinfo3['name'] . "'s defense roll is " . $playerdefense . "<br>";
if ($creatureattack > $playerdefense)
{
echo $creature . " hits! <br>";
$creaturedamage = rand(1,6);
$newplayerhp = $playerhp - $creaturedamage;
echo "For " . $creaturedamage . " points of damage. <br>";
if ($newplayerhp < 1)
{
echo $playerinfo3['name'] . " has been killed<br>";
echo "<a href='gameover.php'>Continue";
exit;
}
$updateplayer="update players set hpoints='$newplayerhp' where name='player1'";
mysql_query($updateplayer) or die("Could not update player");
}
else
{
echo $creature . " misses!";
}
echo "<br><br><a href='battle.php?creature=$creature'>Battle Again!";
?>
- hallsofvallhalla
- Site Admin
- Posts: 12023
- Joined: Wed Apr 22, 2009 11:29 pm
Re: Help
a typo in your code
should be
you have a T in there
Code: Select all
if (isset($_SESSTION['player']))
Code: Select all
if (isset($_SESSION['player']))