function login() { $controllerAuthentication = new ControllerAuthentication(); $auth = $controllerAuthentication->login($_POST['username'], md5($_POST['password'])); if ($auth != null) { $_SESSION['name'] = $auth->name; header("Location: home.php"); } else { echo "<script>alert('Invalid Username/Password.');</script>"; } }
<?php session_start(); $_SESSION['name'] = ""; require 'controllers/ControllerAuthentication.php'; $controller = new ControllerAuthentication(); if (isset($_POST['submit'])) { $auth = $controller->login($_POST['username'], md5($_POST['password'])); if ($auth != null) { $_SESSION['name'] = $auth->name; // header("Location:home.php"); echo "<script type='text/javascript'>location.href='home.php';</script>"; } else { echo "<script>alert('Invalid Username/Password.');</script>"; } } ?> <!DOCTYPE html> <html lang="en"><head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <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=""> <link rel="shortcut icon" href="http://getbootstrap.com/assets/ico/favicon.ico"> <title>RealEstate Finder Signin</title>