Need Help with Register and Reguser.[Solved]
Posted: Tue Oct 04, 2011 10:36 pm
Well I am trying to have players be able to create characters on my game, on a players account.
Everytime I try to make a new character on my account, all I get is "could not register."
No error or anything.
Here's the full code for this page.
I've debugged the error into this code.
Reg user
and the registration page
Everytime I try to make a new character on my account, all I get is "could not register."
No error or anything.
Here's the full code for this page.
I've debugged the error into this code.
Code: Select all
elseif ($type == "bronze" )
{
if ($playerinfo3['credits'] < 1000)
{
echo "You do not have enough Credits to create this Warrior!";
echo "<p><center>You can buy more credits <a href='store.php'>Here</a></center></p>";
exit;
}
else
{
$bronze = 1000;
$SQL = "INSERT into warriors(pid, pname,name, speed,power,magic,range,defense,vision,luck,health,agility,exper,level,mana,type,hpoints,maxhpoints,maxmana,gold) VALUES ('$pid','$pname','$warrior','1','1','1','1','1','1','1','1','1','0','1','10','$type','10','10','10','250')";
mysql_query($SQL) or die("could not register2");
$updateplayer="update players set credits=credits-'$bronze' where name='$player'";
mysql_query($updateplayer) or die("Could not update player");
} }Code: Select all
<?php
$playerinfo="SELECT * from players where name='$player'";
$playerinfo2=mysql_query($playerinfo) or die("could not get player stats!");
$playerinfo3=mysql_fetch_array($playerinfo2);
$pid=$playerinfo3['userid'];
$pname=$playerinfo3['name'];
$credits=$playerinfo3['credits'];
$warrior=$_POST['warrior'];
$type=$_POST['type'];
$mage=$_POST['mage'];
if ($warrior == "")
{
echo "<p>You didn't enter a Warrior Name!</p>";
echo "<p> <A href='createwarrior.php'>Go back</a></p>";
exit;
}
if ($type == "")
{
echo "<p>You didn't select the type of Warrior you want to create!</p>";
echo "<p> <A href='createwarrior.php'>Go back</a></p>";
exit;
}
$isplayer="SELECT * from warriors where name='$warrior'";
$isplayer2=mysql_query($isplayer) or die("Could not query players table");
$isplayer3=mysql_fetch_array($isplayer2);
if($isplayer3 || strlen($warrior)>25 || strlen($warrior)<1)
{
print "There is already a Warrior of that name or the name you specified is over 25 letters or less than 1 letter";
echo " <A href='createwarrior.php'>Go back</a><br>";
}
if ($type == "free" )
{
$SQL = "INSERT into warriors(pid, pname, name, speed, power, magic, range, defense, vision, luck, health, agility, exper, level, mana, type, hpoints, maxhpoints, maxmana, gold) VALUES ('$pid','$pname','$warrior','1','1','1','1','1','1','1','1','1','0','1','10','$type','10','10','10','100')";
mysql_query($SQL) or die("could not register");
}
elseif ($type == "bronze" )
{
if ($playerinfo3['credits'] < 1000)
{
echo "You do not have enough Credits to create this Warrior!";
echo "<p><center>You can buy more credits <a href='store.php'>Here</a></center></p>";
exit;
}
else
{
$bronze = 1000;
$SQL = "INSERT into warriors(pid, pname, name, speed, power, magic, range, defense, vision, luck, health, agility, exper, level, mana, type, hpoints, maxhpoints, maxmana, gold) VALUES ('$pid','$pname','$warrior','1','1','1','1','1','1','1','1','1','0','1','10','$type','10','10','10','250')";
mysql_query($SQL) or die("could not register");
$updateplayer="update players set credits=credits-'$bronze' where name='$player'";
mysql_query($updateplayer) or die("Could not update player");
} }
elseif ($type == "silver" )
{
if ($playerinfo3['credits'] < 1800)
{
echo "You do not have enough Credits to create this Warrior!";
echo "<p><center>You can buy more credits <a href='store.php'>Here</a></center></p>";
exit;
}
else
{
$silver = 1800;
$SQL = "INSERT into warriors(pid, pname, name, speed, power, magic, range, defense, vision, luck, health, agility, exper, level, mana, type, hpoints, maxhpoints, maxmana, gold) VALUES ('$pid','$pname','$warrior','2','2','2','2','2','2','2','2','2','0','2','20','$type','20','20','20','500')";
mysql_query($SQL) or die("could not register");
$updateplayer="update players set credits=credits-'$silver' where name='$player'";
mysql_query($updateplayer) or die("Could not update player");
} }
elseif ($type == "gold" )
{
if ($playerinfo3['credits'] < 3250)
{
echo "You do not have enough Credits to create this Warrior!";
echo "<p><center>You can buy more credits <a href='store.php'>Here</a></center></p>";
exit;
}
else
{
$gold = 3250;
$SQL = "INSERT into warriors(pid, pname, name, speed, power, magic, range, defense, vision, luck, health, agility, exper, level, mana, type, hpoints, maxhpoints, maxmana, gold) VALUES ('$pid','$pname','$warrior','4','4','4','4','4','4','4','4','4','0','4','40','$type','40','40','40','1000')";
mysql_query($SQL) or die("could not register");
$updateplayer="update players set credits=credits-'$gold' where name='$player'";
mysql_query($updateplayer) or die("Could not update player");
}}
else if ($type == "platinum")
{
if ($playerinfo3['credits'] < 5750)
{
echo "You do not have enough Credits to create this Warrior!";
echo "<p><center>You can buy more credits <a href='store.php'>Here</a></center></p>";
exit;
}
else
{
$plat = 5750;
$SQL = "INSERT into warriors(pid, pname, name, speed, power, magic, range, defense, vision, luck, health, agility, exper, level, mana, type, hpoints, maxhpoints, maxmana, gold) VALUES ('$pid','$pname','$warrior','10','10','10','10','10','10','10','10','10','0','10','100','$type','100','100','100','2500')";
mysql_query($SQL) or die("could not register");
$updateplayer="update players set credits=credits-'$plat' where name='$player'";
mysql_query($updateplayer) or die("Could not update player");
}}
if ($mage=1)
{
if ($playerinfo3['credits'] < 5000)
{
echo "You do not have enough Credits for the Mage Boost!";
echo "<p><center>You can buy more credits <a href='store.php'>Here</a></center></p>";
exit;
}
else
{
$warriorinfo="SELECT * from warriors where name='$warrior'";
$warriorinfo2=mysql_query($warriorinfo) or die("Could not query players table");
$warriorinfo3=mysql_fetch_array($warriorinfo2);
$magelvl=$warriorinfo3['magic'];
$manalvl=$warriorinfo3['mana'];
$maxmana=$warriorinfo3['maxmana'];
$updatewarrior="update warriors set `$magelvl`=`$magelvl`+10,`$manalvl`=`$manalvl`+100,`$maxmana`=`$maxmana`+100 where name='$warrior'";
mysql_query($updateplayer) or die("Could not update player");
}}
?>Code: Select all
<form action="regwarrior.php" method="POST" />
<p>Warrior's Name:<input type="text" name="warrior" size="25"></p>
<p>Player Type <select name="type">
<option value="free">Free</option>
<option value="bronze">Bronze (1000 Credits)</option>
<option value="silver">Silver (1800 Credits)</option>
<option value="gold">Gold (3250 Credits)</option>
<option value="platinum">Platinum (5750 Credits)</option></p>
</select>
<p>Mage Boost +10 Levels and +100 Mana(5000 Credits)<input type="checkbox" name="mage" value="mage" /></p>
<p><input type="submit" value="Create" name="create" /></p>
</form>