Login Trouble

Location of the Videos
Post Reply
ricoshade
Posts: 21
Joined: Thu Dec 23, 2010 2:17 am

Login Trouble

Post by ricoshade »

Hello im up to video 5 on the mmo tutorial
When i try log on it says it is wrong so i deleted the account and created a new one. Tried it again and it kept on saying the same. Then i tried Player1 and it worked. Can some one help me out?


Here is the auth page i called it checklgn.php

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

$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='index.php'>Continue</a></big>";
}
else
{
echo "<big>Wrong username or password.<A href='login.php'>Try Again</a></big>";
}
}
?>

And here is the login page i called it login.php

<title>TEST LOGIN INFO</title>
<form method="POST" action="checklgn.php">
User Name <input type="text" name="player" size="21">
<br>
Password <input type="password" name="password" size="21" mask="x">
<br>
<input type="submit" value="Test" name="submit">

<br><br>Not Registered? <a href='register.php'>Register

If i have any errors please tell me :D
alexander19
Posts: 180
Joined: Fri Apr 02, 2010 1:05 pm

Re: Login Trouble

Post by alexander19 »

Try to use the code tags next time...it will allow us to view the code better.

Code: Select all

$query = "select name,password from players where name='$player' and '$password'";
It should probably be :

Code: Select all

$query = "select name,password from players where name='$player' and password='$password'";
Last edited by alexander19 on Thu Dec 23, 2010 2:32 pm, edited 1 time in total.
User avatar
hallsofvallhalla
Site Admin
Posts: 12026
Joined: Wed Apr 22, 2009 11:29 pm

Re: Login Trouble

Post by hallsofvallhalla »

yep thats it
ricoshade
Posts: 21
Joined: Thu Dec 23, 2010 2:17 am

Re: Login Trouble

Post by ricoshade »

i tried it and it didnt work??? when i go on to phpmyadmin and enter the password it gives (hdnjfklsndflsk9423jdas this sort password) and it logs in but when i enter the password i used to register it it keeps on saying its wrong?
User avatar
hallsofvallhalla
Site Admin
Posts: 12026
Joined: Wed Apr 22, 2009 11:29 pm

Re: Login Trouble

Post by hallsofvallhalla »

ah you are missing

$password = md5($password);
ricoshade
Posts: 21
Joined: Thu Dec 23, 2010 2:17 am

Re: Login Trouble

Post by ricoshade »

and were do i put that?
User avatar
Callan S.
Posts: 2042
Joined: Sun Jan 24, 2010 5:43 am

Re: Login Trouble

Post by Callan S. »

Just put it underneath

Code: Select all

$password=strip_tags($password);
Fight Cycle : My latest Browser game WIP
Driftwurld : My Browser Game WIP
Philosopher Gamer : My Blog
ricoshade
Posts: 21
Joined: Thu Dec 23, 2010 2:17 am

Re: Login Trouble

Post by ricoshade »

Now im getting stuck on the register?

Register.php:
<?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">

And heres my reguser.php
<?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)<5)
{
print "There is already a player of that name or the name you specified is over 16 letters or less than 5 letters";
echo " <A href='register.php'>Go back</a><br>";
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";
echo " <A href='register.php'>Go back</a><br>";
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";
echo " <A href='register.php'>Go back</a><br>";
exit;
}
echo " <A href='login.php'>Login Page</a><br>";
?>

when i try register it keeps on saying 'could not register'
User avatar
Callan S.
Posts: 2042
Joined: Sun Jan 24, 2010 5:43 am

Re: Login Trouble

Post by Callan S. »

Check that

Code: Select all

name, password, email, level, exper,
are in the database

Also I'm not sure, but as we know comp languages are grammer nazi's

Code: Select all

"INSERT into players(name, password, email, level, exper,)
You've left an extra comma after exper

Actually I think I did that myself once, constructing the line with a for loop and I had to trim that extra comma it put in. Darn grammer nazi languages...
Fight Cycle : My latest Browser game WIP
Driftwurld : My Browser Game WIP
Philosopher Gamer : My Blog
ricoshade
Posts: 21
Joined: Thu Dec 23, 2010 2:17 am

Re: Login Trouble

Post by ricoshade »

Crap that stupid comma ive been looking all though heaps of forums and it was just a comma thx alot :D
Post Reply

Return to “Older Browser MMO Videos”