Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public function init() {
- return new DatabaseManager('localhost','root','49254975','yumenet');
- }
- public function login(){
- if(isset($_POST['username'], $_POST['password'])) {
- if (empty($_POST['username']) && empty($_POST['password'])) {
- echo '<div id="alert">Bitte fülle alle Felder aus!</div>';
- } else {
- $username = $_POST['username'];
- $password = $_POST['password'];
- $db = self::init()->getOut("SELECT * FROM yume_users WHERE username = '" . $username . "' AND password = '".sha1($password)."'");
- $db->execute();
- $output = $db->fetchObject();
- if ($output->username == $username && $output->password == sha1($password)) {
- $_SESSION['username'] = $output->username;
- $_SESSION['password'] = $output->password;
- $_SESSION['token'] = rand(1000, 20);
- header('Location: ./dashboard');
- } else {
- echo '<div id="alert">Benutzername oder Passwort falsch</div>';
- }
- }
- }
- }
- public function register(){
- if(isset($_POST['re_username'], $_POST['re_password'], $_POST['re_password2'], $_POST['re_email'])) {
- if (empty($_POST['re_username']) && empty($_POST['re_password']) && empty($_POST['re_password2']) && empty($_POST['re_email'])) {
- echo '<div id="alert">Bitte fülle alle Felder aus!</div>';
- } else {
- $username = $_POST['re_username'];
- $password = $_POST['re_password'];
- $db = self::init()->getOut("SELECT * FROM yume_users WHERE username = '" . $username . "'");
- $db->execute();
- $output = $db->fetchObject();
- if($output->num_rows > 0 ){
- echo '<div class="error">Benutzername ist bereits vergeben!</div>';
- } else {
- $db = self::init()->getOut("INSERT INTO yume_users (username, password, avatar) VALUES ('".$username."', '".sha1($password)."', 'yume-32')");
- $db->execute();
- $_SESSION['username'] = $username;
- $_SESSION['token'] = rand(1000, 20);
- header('Location: /dashboard');
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement