SchokoBrunnen
Mitglied
Ich hab ein Usersystem, mit Register,Login,logout und config (aus Google). Aber bei mir kommt ein Fehler, wenn ich auf register.php oder login.php gehe. Es gibt mir eine Fehlermeldung :
In dieser Linie ist aber dashier :
Keine Ahnung was falsch ist, versuche es schon seit 1 Stunde..
Hier mal die ganzen Codes :
config.php
Das mit Datenbank User usw. hab ich schon verändert,die sind auch 100% richtig.
login.php
logout.php
register.php
Wo liegt das Problem ?
Parse error: syntax error, unexpected T_EXIT, expecting ',' or ';' in /users/*****/www/register.php on line 46
In dieser Linie ist aber dashier :
PHP:
die();
Keine Ahnung was falsch ist, versuche es schon seit 1 Stunde..
Hier mal die ganzen Codes :
config.php
PHP:
<?php // Defines the database information. Change to your own info. define('DB_USER','DatenbankUser'); define('DB_PASS','Datenbank Passwort'); define('DB_NAME','Datenbankname'); // Connects to the database. $conn = mysql_connect('localhost',DB_USER,DB_PASS); $select = mysql_select_db(DB_NAME,$conn); // This function creates a hash instead of storing passwords plaintext. Change abc to anything you want function encrypt($str) { $str = trim($str); $str = md5($str); return $str; } // This function strips input of any tags or special characters. function clean($str) { $str = trim($str); if(!mysql_real_escape_string()) { $str = addslashes($str); } $str = strip_tags(htmlspecialchars($str)); return $str; } // Checks to see if user is logged in. if(isset($_SESSION['username']) && isset($_SESSION['password'])) { $query = mysql_query("SELECT password FROM users WHERE username = '{$_SESSION['username']}'"); if(!$query || mysql_num_rows($query) < 1) { unset($_SESSION['username']); unset($_SESSION['password']); $loggedin = false; } else { $loggedin = true; } } else { $loggedin = false; } // Gets an array with the user's information in it. $query = mysql_query("SELECT * FROM users WHERE username = '{$_SESSION['username']}'"); $users = mysql_fetch_array($query); ?>
Das mit Datenbank User usw. hab ich schon verändert,die sind auch 100% richtig.
login.php
PHP:
<?php session_start(); // Loads the config file require_once 'config.php'; // If the user is already logged them stop them from viewing the page. if($loggedin) { die('You are already logged in.'); } // If they have submitted the form if(empty($_POST['login']) === false) { // Clean input and encrypt password $username = clean($_POST['username']); $password = encrypt($_POST['password']); // If they left a field blank if(!$_POST['username'] || !$_POST['password']) { $errors[] = 'You left a field blank.'; } // Checks to see if the username and password match. $query = mysql_query("SELECT password FROM users WHERE username = '$username'"); // If the username doesn't exist, error them if(!$query || mysql_num_rows($query) < 1) { $errors[] = 'Username does not exist.'; } // If the username/password is wrong, error them. $login = mysql_fetch_array($query); if($password != $login['password']) { $errors[] = 'Wrong username/password.'; } // If there are any errors, echo them. if($errors) { foreach($errors as $disperrors) { echo $disperrors.'<br />'; } echo 'Click <a href="login.php">here</a> to go back.' die(); } // Add the username and password to the session $_SESSION['username'] = $username; $_SESSION['password'] = $password; // Success message if there are no errors. echo 'Thanks for logging in. <a href="index.php">Main page</a>.'; // Otherwise echo form } else { echo ' <form method="post" action=""> Username: <br /> <input type="text" name="username" /> <br /> <br /> Password: <br /> <input type="password" name="password" /> <br /> <br /> <input type="submit" value="Login" name="login" /> </form> '; } ?>
logout.php
PHP:
<?php session_start(); // Load configuration require_once 'config.php'; // If the user isn't logged in, they can't logout. if(!$loggedin) { die('You need to be logged in to logout.'); } else { // Gets rid of the session information unset($_SESSION['username']); session_destroy(); // Lets them know they logged out. echo 'You have successfully logged out.'; } ?>
register.php
PHP:
<?php session_start(); // Loads the config file so we can use some stuff from it. require_once 'config.php'; // Checks to see if the user is already logged in. if($loggedin) { die('You are already logged in.'); } // If the user hasn't submitted the form if(empty($_POST['register']) === false) { // Create an array to store errors $errors = array(); // Cleans the input and ecnrypts the password $username = clean($_POST['username']); $password = encrypt($_POST['password']); // If they left a field empty if(!$_POST['username'] || !$_POST['password']) { $errors[] = 'You left a field blank'; } // If the username they entered is longer than 30 characters. if(strlen($username) > 30) { $errors[] = 'Your username cannot exceed 30 characters.'; } // Checks to see if the username is in the database $query = mysql_query("SELECT username FROM users WHERE username = '$username'"); $count = mysql_num_rows($query); // If the username is in the database, error them if($count > 0 ) { $errors[] = 'That username is already taken. Please choose another one.'; } // Echos the errors. if($errors) { foreach($errors as $disperrors) { echo $disperrors.'<br />'; } echo 'Click <a href="register.php">here</a> to go back.' die(); } // If there are no errors, we can now add them to the database. $query = mysql_query("INSERT INTO users (username , password) VALUES('$username' , '$password')"); // Success message echo 'You have successfully registered, '.$username.'! You may now <a href="login.php">login</a>.'; // If they haven't submitted the form } else { echo ' <form method="post" action=""> Username: <br /> <input type="text" maxlength="30" name="username" /> <br /> <br /> Password: <br /> <input type="password" maxlength="30" name="password" /> <br /> <br /> <input type="submit" value="Register" name="register" /> </form> '; } ?>
Wo liegt das Problem ?