forked from JarekSed/Manny-Blog
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
47 lines (43 loc) · 1.3 KB
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<!DOCTYPE html>
<html lang="en">
<head>
<title>Manny's Blogpost</title>
</head>
<body>
<?php
require_once("common.php");
?>
<h3>Manny's BlogPost</h3>
<?php
if(isset($_SESSION['username'])){ //home page if user is logged in
echo " Hello " . $_SESSION['username'] . "</br>"; // use "."to concatinate in php
?>
<a href = "post.php">make a post</a></br>
</br>
<?php
getPosts();
?>
<form name = "logout" action= "login.php" method = "post">
<input type = "submit" name = "logoutButton" value = "Log Out"/>
</form>
<?php
}
else{ //if user inputs invalid login information
if(isset($_SESSION['loginFail'])){
echo $_SESSION['loginFail'] . "</br>";
echo "login fail";
unset($_SESSION['loginFail']);
}
//default home page
?>
<form name = "login" action= "login.php" method = "post">
<strong>Username: </strong><input type = "text" name = "username"/></br>
<strong>Password: </strong><input type = "password" name = "password"/></br>
<input type = "submit" value = "Log In" />
</form></br>
<a href = "register.php"><strong>Register</strong></a></br>
<?php
}
?>
</body>
</html>