예제 #1
0
파일: login.php 프로젝트: raymondas/mlmapp
<?php

include 'config.php';
if (empty($_POST) === false) {
    $username = $_POST['username'];
    $password = $_POST['password'];
    if (empty($username) === TRUE || empty($password) === TRUE) {
        $errors[] = 'You need to enter a username and password';
    } elseif (member_exists($username) === false) {
        $errors[] = 'Username does not exist. Please register';
    } elseif (member_active($username) === FALSE) {
        $errors[] = 'You account isn`t activated. An activation link was sent to your e-mail. Follow it';
    } else {
        $login = login($username, $password);
        if ($login === FALSE) {
            $errors[] = 'Username or password is in correct';
        } else {
            echo 'Success';
            // Set session variables
            $memberID = member_id_from_username($username);
            //set username session
            $_SESSION["username"] = $username;
            //set user id session
            $_SESSION["memberID"] = $memberID;
            //set user password session
            $_SESSION["password"] = $password;
            //redirect to dashbord
            header("location: dashboard.php");
        }
    }
    print_r($errors);
예제 #2
0
    }
    if ($password !== $cpassword) {
        $errors[] = "Password doesn`t match";
    }
    if ($username_length < 6 || $username_length > 32) {
        $errors[] = "Username must be 6-32 characters";
    }
    if ($password_length < 6 || $password_length > 32) {
        $errors[] = "Password must be 6-32 characters";
    }
    if (validate_email($email) == FALSE) {
        $errors[] = "Email {$email} not valid. Please enter a valid email";
    }
    print_r($errors);
    if (empty($errors) == TRUE) {
        if (member_exists($username)) {
            header("Location: register.php?error='User already exist'");
            die;
        } else {
            register($username, $email, $password);
        }
    }
}
/*
if(!empty($username) || !empty($password) || !empty($vpassword)|| !empty($email) ){
  if ($username_length < 6) {
    //redirect back to registeration page with error
    header("Location:register.php?error='Username should be at least characters'");
  }elseif($password !==$cpassword) {
    $errors[]="Passwords doesn't match";
    die($errors);