Wie man schon oben lesen kann habe ich ein Problem mit dem login system es will einfach nicht funktionieren dass gleiche ist mit dem register system genau so.
ich benutze Smarty 3.1.2 benuze als haupt klasse Smary.class.php.
login.php:
PHP
<?phpif(isset($_SESSION['username'])) { header("Location: index.php"); }session_start();if(isset($_POST['submit'])){ $Username = $db->real_escape_string($_POST['username']); $Password = $db->real_escape_string($_POST['password']); $CheckAcc = $db->query("SELECT id FROM users WHERE username = '$Username' AND password = '$Password' LIMIT 1"); if($db->num_rows($CheckAcc)) { $_SESSION['username'] = $Username; header("Location: index.php"); } else { echo 'Die angegebenen Benutzerdaten, scheinen nicht korrekt zu sein!'; }}?><html lang="en"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="description" content=""> <meta name="author" content=""> <title> {$title_Firm} - Login</title> <!-- Bootstrap core CSS --> <link href="{$system_style}css/bootstrap.min.css" rel="stylesheet"> <!-- Custom styles for this template --> <link href="{$system_style}css/signin.css" rel="stylesheet"> <!-- Just for debugging purposes. Don't actually copy these 2 lines! --> <!--[if lt IE 9]><script src="../../assets/js/ie8-responsive-file-warning.js"></script><![endif]--> <script src="{$system_style}js/ie-emulation-modes-warning.js"></script> <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries --> <!--[if lt IE 9]> <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script> <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script> <![endif]--> </head> <body> <div class="container"> <form class="form-signin" role="form" method="post"> <h2 class="form-signin-heading">Bitte Einloggen</h2> <label for="inputtext" class="sr-only">Benutzername</label> <input type="text" id="inputEmail" class="form-control" placeholder="Benutzername" name="username" autofocus> <br> <label for="inputpassword" class="sr-only">Passwort</label> <input type="password" id="inputPassword" class="form-control" placeholder="Passwort" name="password"> <div class="checkbox"> <label> Noch nicht Registriert,dann <a href="register.php">hier</a> entlang. </label> </div> <button class="btn btn-lg btn-primary btn-block" type="submit" name="submit">Login</button> </form> </div> <!-- /container --> <!-- IE10 viewport hack for Surface/desktop Windows 8 bug --> <script src="{$system_style}js/ie10-viewport-bug-workaround.js"></script> </body></html>
Fehler ausgabe:
PHP
real_escape_string($_POST['username']); $Password = $db->real_escape_string($_POST['password']); $CheckAcc = $db->query("SELECT id FROM users WHERE username = '$Username' AND password = '$Password' LIMIT 1"); if($db->num_rows($CheckAcc)) { $_SESSION['username'] = $Username; header("Location: index.php"); } else { echo 'Die angegebenen Benutzerdaten, scheinen nicht korrekt zu sein!'; } } ?>
in der index.php sieht es so aus:
PHP
<?php error_reporting(E_ALL); ini_set('display_errors', 1); ini_set('session.use_only_cookies', 1); if(session_status() == PHP_SESSION_NONE){ session_start(); } define('Local_Dir','system/'); $_SESSION['loggedin'] = false; include Local_Dir.'config/config.php'; //include_once Local_Dir.'classes/core.class.php'; include_once 'system/classes/TestProjektSmarty.class.php'; //core::LoadConfig("de_Config"); //core::initLanguageSystem("de_DE","de"); $smarty = new TestProjektSmarty(); include Local_Dir.'language/de/'.$configSett['Lang'].'.lang.php'; $page = addslashes($_REQUEST['page']); if (empty($page)) { $page = "home"; } $file = $page; if(file_exists('./templates/'.$file.'.php')){ include('./templates/'.$file.'.php'); } $smarty->display(Local_Dir.'templates/'.$page.'.php');//dass erwirkt den url http://yourip/index.php?page=login oder ?page=home // Local_Dir.'templates/'.$page.'.php'?>
nicht wundern wenn core sachen diren sind ist ausgeklammert
Eine ist es möglich es auch als class oder Bachend anwendung machhne zu können.