-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
68 lines (60 loc) · 2.71 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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
<?php
session_start();
require "config.php";
?>
<html>
<head>
<link rel="stylesheet" type="text/css" href="styles/main.css">
</head>
<body>
<?php
//print_r($_SESSION);
//*****************************************
//user credentials
$loggedin = false;
if(isset($_SESSION['username']) && isset($_SESSION['password']))
{
$username = $_SESSION['username'];
$password = $_SESSION['password'];
$result = mysql_query("select * from users where (users_username = '".$username."' or users_email = '".$username."') and (users_password = '".$password."')");
if(mysql_num_rows($result) != 0)
{
//printf("<a href=logout.php>Logout</a><div align=right>Welcome <b><font size=5>".$username."</font></b></div>");
$row = mysql_fetch_array($result);
printf("<a href=logout.php>Logout</a><div align=right>Welcome <b><font size=5><a href=profile.php>".$username.'</a> <img src='.$row['users_photourl'].' width=50 height=50>'."</font></b></div>");
$loggedin = true;
}
else
{
printf('<div align=right><h3><a href="login.php">Login</a> <a href="signup.php">Register</a></h3></div>');
}
}
else
{
printf('<div align=right><h3><a href="login.php">Login</a> <a href="signup.php">Register</a></h3></div>');
}
//Print the posts on the screen
$result = mysql_query("select * from posts");
while ($row = mysql_fetch_array($result))
{
$title = $row['posts_title'];
$content = $row['posts_content'];
$date = $row['posts_date'];
$username = $row['posts_username'];
printf("<font color=red><h1>$title</h1></font>");
printf("<h6>$username $date</h6>");
printf("<p>$content</p>");
printf("<hr>");
}
if($loggedin)
{
printf("<h2>Add a post!</h2>");
printf('<form name=post_form action=add_post.php method="get">');
printf('<input type=text value="Title here" name=title><br>');
printf("<textArea name=post></textArea><br>");
printf('<input type=submit value="Add Post">');
printf('</form>');
}
?>
</body>
</html>