Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- //COntroller
- /**
- * Class Songs
- * This is a demo class.
- *
- * Please note:
- * Don't use the same name for class and method, as this might trigger an (unintended) __construct of the class.
- * This is really weird behaviour, but documented here: http://php.net/manual/en/language.oop5.decon.php
- *
- */
- class Session extends Controller
- {
- /**
- * PAGE: index
- * This method handles what happens when you move to http://yourproject/songs/index
- */
- public function index()
- {
- }
- public function register()
- {
- if ($_SERVER["REQUEST_METHOD"] == "POST") {
- $password1 = $_POST["password1"];
- $password2 = $_POST["password2"];
- if ($password1 == $password2) {
- $username = $_POST["username"];
- $lastname = $_POST["lastname"];
- $email = $_POST["email"];
- $password1 = $_POST["password1"];
- $password2 = $_POST["password2"];
- //encript password
- $password1 = md5(md5("joasdjf".$password1."jwdfgsadfas"));
- // if not
- if(!(!isset($username) || trim($username) == '' || !isset($lastname) || trim($lastname) == '' || !isset($email) || trim($email) == '' || !isset($password1) || trim($password1) == '' || !isset($password2) || trim($password2) == ''))
- {
- if ($users = $this->model->createNewUser($username,$lastname,$email,$password1,$password2)) {
- header('Location: http://mvc.balkangaming.net');
- }
- }
- }else echo " ";
- }
- var_dump($this->model->userLoggedIn());
- require APP . 'view/_templates/header.php';
- require APP . 'view/session/register.php';
- require APP . 'view/_templates/footer.php';
- }
- public function login()
- {
- if ($_SERVER["REQUEST_METHOD"] == "POST") {
- $username = $_POST["username"];
- $password = $_POST["password"];
- if (!isset($username) || trim($username) == '' || !isset($password) || trim($password) == '' )
- {
- var_dump($username);
- var_dump($password);
- //encript password
- echo "you did not entered data";
- }
- else {
- $password = md5(md5("joasdjf".$password."jwdfgsadfas"));
- if ($users = $this->model->loginUser($username,$password)) {
- var_dump($users = $this->model->loginUser($username,$password));
- session_start();
- $_SESSION['username'] = $username;
- echo "Logged in successfuly";
- }else echo "Username or password does not match";
- }
- }
- require APP . 'view/_templates/header.php';
- require APP . 'view/session/login.php';
- require APP . 'view/_templates/footer.php';
- }
- public function logout() {
- $this->model->logout();
- header('Location: http://mvc.balkangaming.net/');
- }
- public function checkEmail()
- {
- $email = $_POST["email"];
- $users = $this->model->checkIfEmailExists($email);
- }
- public function checkUsername()
- {
- $name = $_POST["username"];
- $users = $this->model->checkIfUserExists($name);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement