Register for your free account! | Forgot your password?

Go Back   elitepvpers > Coders Den > Web Development
You last visited: Today at 11:41

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



Kleine Php Frage

Discussion on Kleine Php Frage within the Web Development forum part of the Coders Den category.

Reply
 
Old   #1
 
elite*gold: 30
Join Date: May 2011
Posts: 521
Received Thanks: 69
Kleine Php Frage

hey leute
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 // 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>
hoffe ihr könnt mir helfen
Crystal-Craft is offline  
Old 04/28/2012, 16:32   #2
 
NotEnoughForYou's Avatar
 
elite*gold: 0
Join Date: Jun 2010
Posts: 3,406
Received Thanks: 2,024
1. der center Tag ist veraltet und sollte wegkommen

Überprüf einfach vor deinem Formular ob deine Session name_user existiert, wenn sie existiert bist du ja eingeloggt

--> kleines bsp

PHP Code:
if(isset($_SESSION['user_name'])) {
   
// Menü
}
else {
   
// Formular

übrigens ist dein Script SQLI anfällig
NotEnoughForYou is offline  
Old 04/28/2012, 20:58   #3

 
マルコ's Avatar
 
elite*gold: 1329
Join Date: Jun 2009
Posts: 1,873
Received Thanks: 960
Ich würde sogar so weit gehen, und die Informationen in der Session nochmal prüfen, anstatt nur abzufragen, ob die Infos vorhanden sind. Weil wenn du irgendwo einen Fehler machst, und Session Infos gespeichert werden, dann zählt das sofort als eingeloggt.
マルコ is offline  
Old 04/28/2012, 22:11   #4


 
.Marcel''s Avatar
 
elite*gold: 100
Join Date: Sep 2009
Posts: 8,143
Received Thanks: 2,763
Und ans Escapen denken!
.Marcel' is offline  
Reply


Similar Threads Similar Threads
[FRAGE] Eine Kleine HomePage Frage
10/06/2010 - Metin2 Private Server - 4 Replies
Gameserver-Datenbank SQL-Server (Gameserver) SQL-User (Gameserver) SQL-Passwort (Gameserver) Homepage-Datenbank
[Frage] Eine kleine Frage
05/03/2010 - Metin2 Private Server - 0 Replies
hey kennst jemand von euch Die Codes für Gm sachen beispiel Gm krieger helm der der hilft bekommt thx danke
[Frage] Eine kleine Frage an euch
05/02/2010 - Metin2 Private Server - 3 Replies
Was wünscht ihr euch von einem richtig gutem server schreibt eure vorschläge auf pls ok thx
[FRAGE] STARTERSET!!! KLEINE FRAGE WIRKLICH KLEIN^^ XD
03/19/2010 - Metin2 Private Server - 4 Replies
ES LIEF BEIM TEST CHAR ALLES SUPER AUSSER ER WURDE NICHT LEVEL 99 SONDERN LEVEL 33 WIE KANN ICH DAS ÄNDERN BZW WO LIEGT DER FEHLER?^^ say_title ( "Willkommen" ) say ( "Willkommen auf dem Server LuckboxMt2." ) say ( "Wehe du Hackst dann wirste hier gebannd gekickt und dick in den Arsch gepoppt ne also have Fun" ) say ( "Blubb" ) say ( "" ) command ( "level 99" )



All times are GMT +1. The time now is 11:41.


Powered by vBulletin®
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2025 elitepvpers All Rights Reserved.