Browser MMO Video #3

Location of the Videos
User avatar
FriendlyDragon
Posts: 2
Joined: Thu Mar 11, 2010 12:00 am

Re: Video#3

Post by FriendlyDragon »

Thanks for the quick replies and suggestions. I actually managed to fix the problem by correcting a few mistakes where I had missed a quote or apostraphe. Sorry to have bothered you guys. I'm not sure why the error highlighted line 57... I guess that one of the quotes or apostraphes in line 57 could have been incorrectly considered a closing/opening quote/apostraphe because I'd missed one out elsewhere?

Thanks for your advice Halls (about watching the videos before getting started with scripting anything)... I have been watching a video and then going back and typing up the code from it, but if you reckon that watching upto vid 14 ahead of getting starting will give me a better idea of what I'm doing then I'll give that a go. Guess I'm just impatient to get started.

Thanks again.
jyeadon
Posts: 4
Joined: Sun Mar 28, 2010 3:15 am

Re: Video#3

Post by jyeadon »

I'd like to start out by saying thanks for the videos and all your hard work. I have put in the code so far, and when I enter into the text fields and hit submit, it just resets all the fields blank, and even though I start with a page named http://localhost/tutorial/register.php, it changes to http://localhost/tutorial/register.php/reguser.php after I click the submit button. There are no errors, just resets all the input textboxes to blank. I have double checked all my code and my database and it seems like everything is exactly as you have it on the video and in your code. Any help will be appreciated. Thanks.
User avatar
hallsofvallhalla
Site Admin
Posts: 12026
Joined: Wed Apr 22, 2009 11:29 pm

Re: Video#3

Post by hallsofvallhalla »

post your code here for us to look at please.
jyeadon
Posts: 4
Joined: Sun Mar 28, 2010 3:15 am

Re: Video#3

Post by jyeadon »

Here is the code I have typed in:

connect.php
___________

Code: Select all

<?php

$db = mysql_connect ("localhost","root","") or die("Could not connect to database");

if (!$db)
	die ("No dtaabase");

if (!mysql_select_db("tutorial",$db))

	die("No database selected");

?>
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";

</form>
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_tage($email);

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'])
{
echo "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)
{
echo "There is already a player of that name or the name you specified is over 16 letters or under 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 email");
$isaddress3=mysql_fetch_array($isaddress2);
if($isaddress3)
{
echo "There is already a player with that email 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");

echo "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 "<a href='login.php'>Login Page</a><br>";

?>


Sorry if I don't know how to add it to a fancy window like some of the other users.

Thanks.
User avatar
hallsofvallhalla
Site Admin
Posts: 12026
Joined: Wed Apr 22, 2009 11:29 pm

Re: Video#3

Post by hallsofvallhalla »

just use code tags like I have done, edit the post to see.


can i see a screen of when the forms are reset? The form should go away if the page is actually changing. I am not sure how that is happening so I want to see a screen.
jpoisson
Posts: 245
Joined: Sun Aug 02, 2009 5:12 pm

Re: Video#3

Post by jpoisson »

Halls you should just lock all the videos from 1 - 13 and this may convince people that they should watch the videos before attempting to code right away.
jyeadon
Posts: 4
Joined: Sun Mar 28, 2010 3:15 am

Re: Video#3

Post by jyeadon »

Thanks for the reply, and I am still watching and following the videos along. The coding is not confusing to me, just the way my pages are acting is confusing me. I put put the localhost/tutorial/reguser in the browser bar, and it loads up fine. I put info into the textboxes, making sure my password and pass 2 are different, and this is the screen it flashes to:
aftersubmit.jpg
And if I enter valid information with the password and pass2 matching, it does the exact same thing, and adds nothing to the database. I feel this may be the same issue iamyou was having on page 2:Postby iamyou » Wed Sep 30, 2009 1:08 pm. Again thanks for the help, it is not slowing my learning by watching the vids, I just wish I could follow along with the code also, because I learn even more when I type it in myself and watch it grow.
User avatar
hallsofvallhalla
Site Admin
Posts: 12026
Joined: Wed Apr 22, 2009 11:29 pm

Re: Video#3

Post by hallsofvallhalla »

ah i see the problem, look at the url, its still going to register.php but adding /reguser.php

try replacing this in register.php until it works

Code: Select all

<form method="POST" action="reguser.php">
with

Code: Select all

<form method="POST" action="/reguser.php">

Code: Select all

<form method="POST" action="../tutorial/reguser.php">

Code: Select all

<form method="POST" action="http://localhost/tutorial/reguser.php">
jyeadon
Posts: 4
Joined: Sun Mar 28, 2010 3:15 am

Re: Video#3

Post by jyeadon »

Yes, the second piece of code worked wonderfully, ..tutorial/reguser.php Thanks, so much, and it led me to the rest of my debugging.
alexrules01
Posts: 175
Joined: Sun Oct 11, 2009 9:33 am

Re: Video#3

Post by alexrules01 »

Also in your connect.php you spelt database wrong, dunno whether you fixed that up :)
Post Reply

Return to “Older Browser MMO Videos”