ich habe ein login mit php geschrieben und die php abfrage wird in der selben datei ausgeführt wo auch das login formular ist nun meine frage.
nachdem die daten richtig sind will ich ein menü darein machen klappt auch nur das login formular ist noch da. gibt es da eine möglichkeit das weg zu machen ohne das man die php abfrage in eine neue datei tut?
mein code:
PHP Code:
<?php
session_start();
?>
<!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>ShiningNetwork - Panel</title>
<link rel="stylesheet" type="text/css" href="css/style.css">
</head>
<body>
<center>
<?php
if(isset($_POST["user_login"])) {
if (preg_match('/[^a-zA-Z0-9]/',$_POST['username']))
{
die (' <font color="red">Dein Benutzername enthält unerlaubte Zeichen</font> ');
}
else if (empty($_POST['username']))
{
die (' <font color="red">Bitte gebe einen Benutzer namen ein</font> ');
}
else if (preg_match('/[^a-zA-Z0-9]/',$_POST['password']))
{
die (' <font color="red">Dein Password enthält unerlaubte Zeichen</font> ');
}
else if (empty($_POST['password']))
{
die (' <font color="red">Bitte gebe ein Password ein.</font> ');
}
$username = $_POST['username'];
$passwort = md5('kikugalanet' . $_POST['password']);
$user = preg_replace ("[^A-Za-z0-9]", "", $_POST['username']);
$pass = preg_replace ("[^A-Za-z0-9]", "", $passwort);
if($user != $_POST['username'])
{
echo "Fehler beim Login.";
}else{
$connection = mssql_connect("HomeServer-PC\SQLEXPRESS", "", "");
$query = @mssql_query("SELECT account, password FROM [ACCOUNT_DBF].[dbo].[ACCOUNT_TBL] WHERE account = '$user'");
$row = mssql_fetch_object($query);
if($row->password == $pass) {
$panel = @mssql_query("SELECT m_chLoginAuthority FROM [ACCOUNT_DBF].[dbo].[ACCOUNT_TBL_DETAIL] WHERE account = '$user'");
$endpanel = mssql_fetch_object($panel);
$authority = $endpanel->m_chLoginAuthority;
$_SESSION["username"] = $user;
$_SESSION["password"] = $password;
if($authority > F ) // Wenn Login Authority größer als F(Normaler User) ist
{
echo " Your Currently Logged in with ", $_SESSION["username"];
$_SESSION['name_admin'] = $user; // Session festlegen
// Menü(admin) soll hier hin und login formular soll veschwinden
}
elseif($authority == F) // Wenn Login Authority gleich F(Normaler User) ist
{
echo " Your Currently Logged in with ", $_SESSION["username"];
$_SESSION['name_user'] = $user; // Session festlegen
// Menü(user) soll hier hin und login formular soll veschwinden
}
}
}
}
?>
<form method="post">
<input type="text" maxlength="13" name="username" value="Benutzername"><br /><br />
<input type="password" maxlength="16" name="password" value="Kennwort"><br /><br />
<input type="submit" name="user_login" value="Login"><br /><br />
</form>
</center>
</body>
</html>






