Video 9
- SpiritWebb
- Posts: 3107
- Joined: Sun Jul 12, 2009 11:25 pm
Video 9
Question:
If I don't want to add all the hpoints, spoints, etc. and just add the class name to their account when selecting their class, how can I do this? For example, I choose wizard and now in the database wizard was wrote the database. That way on the main page (index.php) I can display their race.
If I don't want to add all the hpoints, spoints, etc. and just add the class name to their account when selecting their class, how can I do this? For example, I choose wizard and now in the database wizard was wrote the database. That way on the main page (index.php) I can display their race.
- hallsofvallhalla
- Site Admin
- Posts: 12023
- Joined: Wed Apr 22, 2009 11:29 pm
Re: Video 9
this is solved in video 11 I think, i added the last part to classes in the last video.
- SpiritWebb
- Posts: 3107
- Joined: Sun Jul 12, 2009 11:25 pm
Re: Video 9
I can't find it. Here is what I have:
reguser:
Register:
I'm wanting someone to be able to choose their race, then that race gets placed in the db in the players "racechoice field." Then in the db I can see what race they are "ie: human" and when they login, upper center shows their race type.
EDIT: When clicking register I get:
Notice: Undefined index: racechoice in C:\wamp\www\Mythuto\reguser.php on line 55
Could not register
line 55 is $SQL = "INSERT into ... "
reguser:
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);
$racechoice=$_POST['racechoice'];
if ($email == "")
{
echo "You didn't enter an 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 didn't enter a password";
echo " <a href='register.php'>Go back</a>";
exit;
}
else if($isplayer3 || strlen($player)>15 || strlen($player)<1)
{
print "There is already a player with that name or the name you specified is over 16 letters or less then 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 email address, please try again!<br>";
echo " < a href='register.php'>Go back</a>";
exit;
}
else
{
$password=md5($password);
$racequery="SELECT * from races where name='$racechoice'";
$racequery2=mysql_query($racequery) or die ("Could not load races.");
$racequery3=mysql_fetch_array($racequery2);
$SQL = "INSERT into players(name, password, email, reputation, rank, racechoice) VALUES ('$player','$password','$email','0','1','$racequery3[racechoice]','1')";
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>";
?>
Code: Select all
<link href="style.css" rel="stylesheet" type="text/css" />
<STYLE type="text/css">
<!--
BODY { background-image:url(registerscreenFinal.jpg);
background-repeat:no-repeat;
background-position:center;
background-attachment:fixed }
-->
</STYLE>
<body bgcolor="black">
<body text="white">
<?php
include 'connect.php';
?>
<div id="reg"> <br><br><br><br><br>
<form method ="post" action="reguser.php">
Desired Username: <input type="text" name="player" size="21"><br><br>
Desired Password: <input type="text" name="password" size "15"><br><Br>
ReType Password: <input type="text" name="pass2" size "15"><br><br>
Current Email Address: <input type="text" name="email" size "60"><br><br>
<?php
print "Desired race: ";
print "<select name='racechoice' length='20'>";
$raceinfo="SELECT * from races";
$raceinfo2=mysql_query($raceinfo) or die("Could not select races");
while ($raceinfo3=mysql_fetch_array($raceinfo2))
{
print "<option>$raceinfo3[Name]</option>";
}
print "</select><br>";
?>
<br>
<Center>
<input type="image" value="submit" src="buttons/register1.png"><a href="login.php"><img src="buttons/back.png" border="0">
</center>
</div>
</form>
EDIT: When clicking register I get:
Notice: Undefined index: racechoice in C:\wamp\www\Mythuto\reguser.php on line 55
Could not register
line 55 is $SQL = "INSERT into ... "
Re: Video 9
So do you want a drop down field with a list of the races??
I am farly sure that it is displayed in one of the videos...
do you need more of a tutorial or explination on how to use these??
I am farly sure that it is displayed in one of the videos...
do you need more of a tutorial or explination on how to use these??
New Site Coming Soon! Stay tuned
- hallsofvallhalla
- Site Admin
- Posts: 12023
- Joined: Wed Apr 22, 2009 11:29 pm
Re: Video 9
change this
to$SQL = "INSERT into players(name, password, email, reputation, rank, racechoice) VALUES ('$player','$password','$email','0','1','$racequery3[racechoice]','1')";
Code: Select all
$rchoice = $racequery3['racechoice'];
$SQL = "INSERT into players(name, password, email, reputation, rank, racechoice) VALUES ('$player','$password','$email','0','1','$rchoice','1')";
- SpiritWebb
- Posts: 3107
- Joined: Sun Jul 12, 2009 11:25 pm
Re: Video 9
hallsofvallhalla wrote:change this
to$SQL = "INSERT into players(name, password, email, reputation, rank, racechoice) VALUES ('$player','$password','$email','0','1','$racequery3[racechoice]','1')";
Code: Select all
$rchoice = $racequery3['racechoice']; $SQL = "INSERT into players(name, password, email, reputation, rank, racechoice) VALUES ('$player','$password','$email','0','1','$rchoice','1')";
I tried, and still getting the undefined index racechoice.
I have the drop down menu already in my register screen. But say you go to register, and choose the human race. Well after you click register, I want the word, "Human" placed in the db under "racechoice."Torniquet wrote:So do you want a drop down field with a list of the races??
I am farly sure that it is displayed in one of the videos...
do you need more of a tutorial or explination on how to use these??
Just like how we do the user name placed in the db, but their race choice is just being selected and placed in the db, rather then typing it.
Re: Video 9
Never used a drop down. But this is how im sure it works...
Just liek you $_GET['data']; with the input text boxes.
you would do the same from your drop down menu.
$playerclass = $_GET['value from drop down'];
then when you run the mysql_query you insert the variable '$playerclass' just like other variables.
$query = mysql_query("INSERT INTO player_info (username, pclass) VALUES ('$username', '$playerclass')");
is as simple as that really.
Hope that helps ya
Just liek you $_GET['data']; with the input text boxes.
you would do the same from your drop down menu.
$playerclass = $_GET['value from drop down'];
then when you run the mysql_query you insert the variable '$playerclass' just like other variables.
$query = mysql_query("INSERT INTO player_info (username, pclass) VALUES ('$username', '$playerclass')");
is as simple as that really.
Hope that helps ya
New Site Coming Soon! Stay tuned
- SpiritWebb
- Posts: 3107
- Joined: Sun Jul 12, 2009 11:25 pm
Re: Video 9
Fixed it...I figured out where the problem was. Guess I just needed some "away" time from it. I had on $SQL = "INSERT into players..." The very end of that line, I had ,'1') wrote, and it wasn't being put anywhere. I removed it, tried it again, and it worked!
- SpiritWebb
- Posts: 3107
- Joined: Sun Jul 12, 2009 11:25 pm
Re: Video 9
Now when I try the newly created person, it wont log in, keeps giving me wrong username or password, even though its right.
- hallsofvallhalla
- Site Admin
- Posts: 12023
- Joined: Wed Apr 22, 2009 11:29 pm
Re: Video 9
are you converting your password on log in to md5 also?