diff --git a/var/www/login.php b/var/www/login.php new file mode 100644 index 0000000..82554d2 --- /dev/null +++ b/var/www/login.php @@ -0,0 +1,28 @@ + + + + + + FriendBook Login + + + + +
+

Please Login

+
+ User: +
+ Password: +
+ +
+ + diff --git a/var/www/loginCheck.php b/var/www/loginCheck.php new file mode 100644 index 0000000..f479258 --- /dev/null +++ b/var/www/loginCheck.php @@ -0,0 +1,39 @@ +setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); + echo "Connected successfully"; + if(count($_POST) > 0){ + $matchingUsers = $connection->query("SELECT COUNT(*) FROM login WHERE username = '".$_POST["Username"]."' and pword = '".$_POST["Password"]."'"); + if($matchingUsers > 0){ + // User has been authenticated; set user as logged in + $_SESSION["loggedInUser"] = "".$_POST["Username"].""; + $_SESSION["loginError"] = ""; + // Move onto landing page + header("Location: /landingPage.html"); + die(); + }else{ + // No matching users found, send user error + $_SESSION["loginError"] = "Invalid Username or Password"; + // Return to login page + header("Location: /login.php"); + die(); + } + }else{ + // Return to login page, as credentials were not captured + $_SESSION["loginError"] = "Login credentials not found, please try again"; + header("Location: /login.php"); + die(); + } +} +catch(PDOException $e){ + echo "Error: " . $e->getMessage(); +} +?> \ No newline at end of file diff --git a/var/www/logout.php b/var/www/logout.php new file mode 100644 index 0000000..3b7c9d9 --- /dev/null +++ b/var/www/logout.php @@ -0,0 +1,27 @@ + + + + + + FriendBook Logout + + + + + + + +

You have been successfully logged out.

+ + + diff --git a/var/www/phptest.php b/var/www/phptest.php index 9ffb6a9..4ba50ac 100644 --- a/var/www/phptest.php +++ b/var/www/phptest.php @@ -1,4 +1,6 @@ -

PHP Test Page - Connecting to MySQL

+

PHP Test Page

+ +

Connecting to MySQL

+

PHP Session Info

+ \ No newline at end of file