Login question

Location of the Videos
Post Reply
Feuerqueen
Posts: 7
Joined: Fri Jan 14, 2011 8:47 pm

Login question

Post by Feuerqueen »

I have a problem.
I can register a uder without problems, but I got troubles with showing his stats.

I can log in, but I think it is a session problem. There is no error or something else, it just doesnt show the stats.

Here are my codes

login

Code: Select all

<form method="POST" action="index.php?site=authenticate">
Nickname: <input type="text" name="name" size="21"><br>
Passwort: <input type="password" name="password" size="21">
<br>
<input type="submit" value="Login" name="submit">
authenticate

Code: Select all

<?php
include_once 'connect.php';
session_start();

if (isset($_POST['submit']))
{
  $name=$_POST['name'];
  $password=$_POST['password'];
  $name=strip_tags($name);
  $password=strip_tags($password);
  $password=md5($password);

  $query = "select name,password from user where name='$name' and password='$password'";
  $result = mysql_query($query) or die("Could not query players");
  $result2 = mysql_fetch_array($result);
  if ($result2)
  {
    $_SESSION['name']=$name;
   
    echo "<big>Logged in successfully<br>";
    echo "<A href='index.php?site=profiltabelle'>Continue</a></big>";
  }
  else
  {
   echo "<big>Wrong username or password.<A href='login.php'>Try Again</a></big>";
  }
}
?>
profiltabelle (users stats)

Code: Select all

<?php
include_once 'connect.php';
session_start();

if (isset($_SESSION['name']))
{
  $name=$_SESSION['name'];
}
else
{
  echo "Not Logged in <br><br> <A href='login.php'>Login</a>";
  exit;
}
$playerinfo="SELECT * from user where name='$name'";
$playerinfo2=mysql_query($playerinfo) or die("could not get player stats!");
$playerinfo3=mysql_fetch_array($playerinfo2);
?>
<html>

<head>
<meta http-equiv="Content-Language" content="de">
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Allgemeines</title>
</head>

<body>


<table bgcolor="#878072" border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#40494E" width="100%" height="180">
  <tr>
    <td width="100%" colspan="2" bgcolor="#40494E" align="center" height="10">
    <align="center"><b><font color="#FFFFFF">Allgemeines</font></b></td>
  </tr>
  <tr>
    <td width="50%" align="center" height="19">Name</td>
    <td width="50%" align="center" height="19"><?php echo $user['name']; ?></td>
  </tr>
  <tr>
    <td width="50%" align="center" height="19">e-Mail</td>
    <td width="50%" align="center" height="19"><?php echo $user['eMail']; ?></a></td>
  </tr>
  <tr>
    <td width="50%" align="center" height="19">Geburtstag</td>
    <td width="50%" align="center" height="19"><?php echo $user['geburtstag']; ?></td>
  </tr>
  <tr>
    <td width="50%" align="center" height="19">Geschlecht</td>
    <td width="50%" align="center" height="19"><?php echo $user['geschlecht']; ?></td>
  </tr>
  <tr>
    <td width="50%" align="center" height="19">Dabei Seit</td>
    <td width="50%" align="center" height="19"><?php echo $user['datesignup']; ?></td>
  </tr>
  <tr>
    <td width="100%" align="center" bgcolor="#40494E" colspan="2" height="10">
    <font color="#FFFFFF"><b>Virtuelles</b></font></td>
  </tr>
  <tr>
    <td width="50%" align="center" height="19">Job</td>
    <td width="50%" align="center" height="19">Turnierveranstalter, 
    Zuchtschauenausrichter, Zuchtarbeiter</td>
  </tr>
  <tr>
    <td width="50%" align="center" height="19">Userlevel</td>
    <td width="50%" align="center" height="19"><?php echo $user['userlevel']; echo "mit 2 Punkten"; ?></td>
  </tr>
  <tr>
    <td width="100%" align="center" bgcolor="#40494E" colspan="2" height="10">
    <font color="#FFFFFF"><b>Reiterliches</b></font></td>
  </tr>
  <tr>
    <td width="50%" align="center" height="19"><b>Disziplin</b></td>
    <td width="50%" align="center" height="19"><b>Niveau</b></td>
  </tr>
  <tr>
    <td width="50%" align="center" height="19">Dressur</td>
    <td width="50%" align="center" height="19">E</td>
  </tr>
  <tr>
    <td width="50%" align="center" height="19">Springen</td>
    <td width="50%" align="center" height="19">E</td>
  </tr>
  <tr>
    <td width="50%" align="center" height="19">Military</td>
    <td width="50%" align="center" height="19">E</td>
  </tr>
  <tr>
    <td width="50%" align="center" height="19">Western</td>
    <td width="50%" align="center" height="19">E</td>
  </tr>
  <tr>
    <td width="50%" align="center" height="19">Rennen</td>
    <td width="50%" align="center" height="19">E</td>
  </tr>
  <tr>
    <td width="50%" align="center" height="19">Fahren</td>
    <td width="50%" align="center" height="19">E</td>
  </tr>
  <tr>
    <td width="100%" align="center" bgcolor="#40494E" colspan="2" height="10">
    <font color="#FFFFFF"><b>Lizenzen und Abzeichen</b></font></td>
  </tr>
</table>

<table bgcolor="#878072" border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#40494E" width="100%" height="1">
  <tr>
    <td width="50%" align="center" height="9">
    Turnierlizenz Dressur</td>
    <td width="50%" align="center" height="9">
    Darf E-Turniere reiten</td>
  </tr>
  <tr>
    <td width="49%" align="center" height="10">
    Turnierlizenz Springen</td>
    <td width="51%" align="center" height="10">
    Darf E-Turniere reiten</td>
  </tr>
  <tr>
    <td width="49%" align="center" height="10">
    Turnierlizenz Military</td>
    <td width="51%" align="center" height="10">
    Darf E-Turniere reiten</td>
  </tr>
  <tr>
    <td width="49%" align="center" height="10">
    Turnierlizenz Western</td>
    <td width="51%" align="center" height="10">
    Darf E-Turniere reiten</td>
  </tr>
  <tr>
    <td width="49%" align="center" height="10">
    Turnierlizenz Rennen</td>
    <td width="51%" align="center" height="10">
    Darf E-Turniere reiten</td>
  </tr>
  <tr>
    <td width="49%" align="center" height="10">
    Turnierlizenz Fahren</td>
    <td width="51%" align="center" height="10">
    Darf E-Turniere reiten</td>
  </tr>
  <tr>
    <td width="49%" align="center" height="10">
    Zuchtlizenz</td>
    <td width="51%" align="center" height="10">
    Darf züchten</td>
  </tr></table>
<table bgcolor="#878072" border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#40494E" width="100%" height="1">
  <tr>
    <td width="103%" align="center" bgcolor="#40494E" colspan="5" height="10">
    <font color="#FFFFFF"><b>Erfolge</b></font></td>
  </tr>
  <tr>
    <td width="20%" align="center" height="19"><b>Platzierung</b></td>
    <td width="20%" align="center" height="19"><b>Disziplin</b></td>
    <td width="20%" align="center" height="19"><b>Turnier</b></td>
    <td width="20%" align="center" height="19"><b>Preis</b></td>
    <td width="20%" align="center" height="19"><b>Pferd</b></td>
  </tr>
  <tr>
    <td width="20%" align="center" height="1">-</td>
    <td width="20%" align="center" height="1">-</td>
    <td width="20%" align="center" height="1">-</td>
    <td width="20%" align="center" height="1">-</td>
    <td width="20%" align="center" height="1">-</td>
  </tr>
</table>
</body>
</html>
hope someone can help me :)
Thank you!
Feuerqueen
Posts: 7
Joined: Fri Jan 14, 2011 8:47 pm

Re: Login question

Post by Feuerqueen »

Isn't there anybody who can help me?
User avatar
Jackolantern
Posts: 10891
Joined: Wed Jul 01, 2009 11:00 pm

Re: Login question

Post by Jackolantern »

What do you mean "it doesn't show the stats"? Is that part of the page missing? Does it show all 0's?
The indelible lord of tl;dr
Feuerqueen
Posts: 7
Joined: Fri Jan 14, 2011 8:47 pm

Re: Login question

Post by Feuerqueen »

on the site "profiltabelle.php" I want to show the user information. like name, userlevel, ...

I do this with:

Code: Select all

<?php echo $user['name']; ?>
But when I open the site it doesnt show the name, the field in the table where it should be is empty.

What do I do wrong?

Thank you in advance!
User avatar
Jackolantern
Posts: 10891
Joined: Wed Jul 01, 2009 11:00 pm

Re: Login question

Post by Jackolantern »

What have you done to try to fill that array? I don't see where you have assigned anything to it in that script. Are you sure you did not mean to use $playerinfo3 as the array holding the player's data?
The indelible lord of tl;dr
Feuerqueen
Posts: 7
Joined: Fri Jan 14, 2011 8:47 pm

Re: Login question

Post by Feuerqueen »

Code: Select all

<?php
include_once 'connect.php';
session_start();

if (isset($_SESSION['name']))
{
  $name=$_SESSION['name'];
}
else
{
  echo "Not Logged in <br><br> <A href='login.php'>Login</a>";
  exit;
}
$playerinfo="SELECT * from user where name='$name'";
$playerinfo2=mysql_query($playerinfo) or die("could not get player stats!");
$playerinfo3=mysql_fetch_array($playerinfo2);

 echo $playerinfo3->name;


?>
thats what i tried to do. I tried to give out the name from the player. But it doesnt show anything :(
alexander19
Posts: 180
Joined: Fri Apr 02, 2010 1:05 pm

Re: Login question

Post by alexander19 »

Jack is right...you are using $user when it should have been $playerinfo3:

Code: Select all

<?php echo $user['name']; ?>
should be

Code: Select all

<?php echo $playerinfo3['name']; ?>
Same for the others.
Feuerqueen
Posts: 7
Joined: Fri Jan 14, 2011 8:47 pm

Re: Login question

Post by Feuerqueen »

Thank you VERY much. Now it is working. I have to say. I was a little bit confused about it, but now everything is clear to me. Thank you again!
Post Reply

Return to “Older Browser MMO Videos”