Tag,
ich habe angefangen, mein UCP zu coden, aber habe das Problem, dass wenn ich Namen und Passwort richtig eingebe, zeigt er mir nur wieder das LogIn an. Alles andere funktioniert.
Code:
login.php
PHP
<?php
include("config.php");
session_start();
error_reporting(0);
$submit = $_POST['submit'];
$username = sanitize($_POST['username']);
$password = sanitize($_POST['password']);
if($submit)
{
if($username && $password)
{
$query = mysql_query("SELECT Name, Passwort FROM accounts WHERE Name = '$username'");
if(mysql_num_rows($query) == 1)
{
while($row = mysql_fetch_assoc($query))
{
$dbusername = $row['Name'];
$dbpassword = $row['Passwort'];
}
if($username == $dbusername && $password == $dbpassword)
{
$_SESSION['username'] = $dbusername;
echo header('location: profile.php');
}
else echo "Das Passwort war falsch!";
}
else echo "Es gibt keinen Spieler, mit diesem Namen!";
}
else echo "Du musst einen Namen und ein Passwort eingeben!";
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Basic UCP</title>
<form action='login.php' method='POST'>
<input type="text" name="username" value='<?php echo $username?>'/>
<input type="password" name="password"/>
<input type='submit' name="submit" value='Login' />
</form>
</head>
</html>
Alles anzeigen
profile.php
PHP
<?php
include("config.php");
session_start();
error_reporting(0);
if(isset($_SESSION['username']))
{
$username = $_SESSION['username'];
$query = mysql_query("SELECT * FROM accounts WHERE Name = '$username'");
echo "Willkommen! ".$_SESSION['username'];
while($row = mysql_fetch_assoc($query))
{
$name = $row['Name'];
$money = $row['Geld'];
$score = $row['Level'];
$kills = $row['Kills'];
$deaths = $row['Tode'];
$admlvl = $row['Adminlevel'];
}
echo "<br><br>Name: ".$name."<br> Geld: ".$money."<br> Level: ".$score."<br> Kills: ".$kills."<br> Tode: ".$deaths."<br> Adminlevel: ".$admlvl;
}
else header('location: login.php');
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Basic UCP</title>
</head>
</html>
?>
Alles anzeigen
//edit:
http://ontime.imglol.de/phptest/ucp/login.php/
Name: Key
Passwort: Test