Browser MMO Video #5
- hallsofvallhalla
- Site Admin
- Posts: 12023
- Joined: Wed Apr 22, 2009 11:29 pm
Re: Video#5
change it up how you want, just use it as a base to get started then modify it to make it work for you. No harm in that. Especially if it speeds up development.
Re: Video#5
Here are my login codes:hallsofvallhalla wrote:strange, post your code here, though if I was you I would keep watching the videos as it may fix itself on its own.
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='$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='battle.php'>Continue</a></big>";
}
else
{
echo "<big>Wrong username or password. <a href='login.php'>Try Again</a></big>
}
}
?>
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" />
Re: Video#5
Problem Solved. Missed the last quotation.Klone wrote:Here are my login codes:hallsofvallhalla wrote:strange, post your code here, though if I was you I would keep watching the videos as it may fix itself on its own.
authenticate.php:login.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='$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='battle.php'>Continue</a></big>"; } else { echo "<big>Wrong username or password. <a href='login.php'>Try Again</a></big> } } ?>
The problem is that when I click Login, nothing appears on the authenticate.php page.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" />
Re: Video#5
Where did i go wrong?
I did on autenticate.php the following:
and it written me : Parse error: syntax error, unexpected ';' in C:\wamp\www\tutorial\authenticate.php on line 7
please help.
I did on autenticate.php the following:
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='battle.php'>Continue</a></big>";
)
else
(
echo "<big>Wrong username or password,<a href='login.php'>Try Again</a></big>";
)
)
?>
please help.
- Jackolantern
- Posts: 10891
- Joined: Wed Jul 01, 2009 11:00 pm
Re: Video#5
You are not using the correct braces for your IF statements (something a lot of people do because it is hard to see in the videos):
This...
...needs to be like this:
See how you actually do use ( ) on a function call such as mysql_fetch_array(), but then to create the block of code for branching structures (like IF statements), you actually need to use { } braces. So you use ( ) for IF statement conditions, like in the very first line of the IF statement in the code quoted above, but then once you get into the actual code to be executed based on those conditions, you put it in { } braces.
This...
Code: Select all
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='battle.php'>Continue</a></big>";
)
else
(
echo "<big>Wrong username or password,<a href='login.php'>Try Again</a></big>";
)
)
Code: Select all
if (isset($_POST['submit']))
{ //changed ( to {, and made similar changes all the way down through the code
$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='battle.php'>Continue</a></big>";
}
else
{
echo "<big>Wrong username or password,<a href='login.php'>Try Again</a></big>";
}
}
The indelible lord of tl;dr
Re: Video#5
The curse of the curly brackets strikes again!!!1!
-
- Posts: 165
- Joined: Tue Oct 13, 2009 4:22 pm
Re: Video#5
I got ti the bit in the video where you checked and tryed to log on but i just get: Could not query player.
I cant see anything wrong with my codes, here they are
This is the login.php
This is the authenticate.php
Please check it, if you need any of the he oher scripts tell me
I cant see anything wrong with my codes, here they are
This is the 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">
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='$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>Loggon in Successfully<br/>";
echo "<a href='battle.php'>Continue</a></big>";
}
else
{
echo "<big>Wrong Username or Password.<a href='login.php'>Try Agin</a></big>";
}
}
?>
Im dumb;)
Re: Video#5
after fixing this oriblem, and
THANK YOU VERY MUCH FOR IT
now it tells me:
( ! ) Notice: Undefined index: player in C:\wamp\www\tutorial\authenticate.php on line 7
Call Stack
# Time Memory Function Location
1 0.0028 372560 {main}( ) ..\authenticate.php:0
Wrong username or password,Try Again
what the hell is wrong?
Here is the code again if i missed something:
Valhala said i need no skills in this program and he will teach the viewer all along the way, but with these errors I start to doubt that.
THANK YOU VERY MUCH FOR IT
now it tells me:
( ! ) Notice: Undefined index: player in C:\wamp\www\tutorial\authenticate.php on line 7
Call Stack
# Time Memory Function Location
1 0.0028 372560 {main}( ) ..\authenticate.php:0
Wrong username or password,Try Again
what the hell is wrong?
Here is the code again if i missed something:
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='battle.php'>Continue</a></big>";
}
else
{
echo "<big>Wrong username or password,<a href='login.php'>Try Again</a></big>";
}
}
?>
- hallsofvallhalla
- Site Admin
- Posts: 12023
- Joined: Wed Apr 22, 2009 11:29 pm
Re: Video#5
Once again I would watch until video 14 or so before doing the code
this must be fixed as well
to
make sure you ended your form with </form>
this must be fixed as well
Code: Select all
$query = "select name,password from players where name='$player' and '$password'";
Code: Select all
$query = "select name,password from players where name='$player' and password ='$password'";
Re: Video#5
That's true for the most part - the videos show you everything you need to do. However... if something goes wrong, you need to be able to figure out what happened and how to fix it. So there is some skill needed, but really very little.joedraco wrote:Valhala said i need no skills in this program and he will teach the viewer all along the way, but with these errors I start to doubt that.
It's more about developing the mind set of a programmer.
When you enter code that you saw in the video and it crashes, but it worked in the tutorial, then you have to double check that you entered everything correctly. The code you are doing works in the video, therefore it is good code. If something is not working for you, it's most likely a setup issue (something in your database is not set up the same as Halls') or a typo in your code.
Hang in there, you'll get it. And the more you find and fix these little annoying errors, the more likely you'll be able to spot them in the future