-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathhome.php
More file actions
127 lines (123 loc) · 4.04 KB
/
home.php
File metadata and controls
127 lines (123 loc) · 4.04 KB
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
<?php
//db.php define $db_name and $db_pass which are needed to connect to the db
require("db.php");
/*
//check for post information
*/
$uname = $_POST['uname'];
$pin = $_POST['pin'];
$sql = "SELECT * FROM `Users` WHERE `email` = '{$uname}' AND `pin` = '{$pin}'";
//create the connection
$con = mysql_connect("localhost", $db_name, $db_pass) or die(mysql_error());
//selecet our database
mysql_select_db("cs4400_group53") or die(mysql_error());
//query for username
$result = mysql_query($sql) or die(mysql_error());
if (mysql_num_rows($result) == 1){
//means we have a result
?>
<html>
<head>
<link rel="stylesheet" href="styles/style.css" />
<title></title>
</head>
<body>
<div id='glob_container'>
<div id='header'>
<h1>home page</h1>
</div>
<div id='main_content'>
<h2>Recent CorkBoard Updates</h2>
<a href='pop_tags.html'><button name='pop_tags' value='Popular Tags'>Popular Tags</button></a>
<div id='board_list'>
<?php
$sql4 = "SELECT `CorkBoards`.owner, title, dateAndTime FROM `CorkBoards` INNER JOIN Pushpins WHERE `password` IS NOT NULL ORDER BY `Pushpins`.dateAndTime DESC LIMIT 0, 4";
$result4 = mysql_query($sql4);
while ($row = mysql_fetch_array($result4)){
$sql5 = "SELECT * FROM Users WHERE email='{$row['owner']}'";
$result5 = mysql_query($sql5);
$res5 = mysql_fetch_array($result5);
?>
<a href='viewcb.php?owner=<?php echo($row['owner']) ?>&title=<?php echo($row['title']) ?>&user=<?php echo($uname) ?>'>
<div class='b_node'>
<h4><?php echo($row['title']) ?></h4>
<p>Updated by <em><?php echo($res5['name']) ?></em> on <em><?php echo($row['dateAndTime']) ?></em> at <em>1:49 PM</em></p>
</div>
</a>
<?php } ?>
</div>
<h2>My CorkBoards</h2><a href='add_board.php'><button name='add_board' value='Add CorkBoard'>Add CorkBoard</button></a>
<div id='my_boards'>
<?php
$sql = "SELECT * FROM `CorkBoards` WHERE `owner` = '{$uname}'";
$result = mysql_query($sql) or die(mysql_error());
while ($row = mysql_fetch_array($result)){
$sql2 = "SELECT COUNT(*) FROM `Pushpins` WHERE `owner` = '{$uname}' AND `boardTitle`='{$row['title']}'";
$num = 0;
if ($result2 = mysql_query($sql2)){
$res = mysql_fetch_array($result2);
$num = $res[0];
}
?>
<a href='viewcb.php?owner=<?php echo($uname) ?>&title=<?php echo($row['title']) ?>&user=<?php echo($uname) ?>'>
<div class='my_board'>
<h4><?php echo($row['title']); ?></h4>
<?php
if ($row['password']){
?>
<h4 class='private'>(private)</h4>
<?php } ?>
<p>with <?php echo("$num") ?> PushPins</p>
</div>
</a>
<?php } ?>
</div>
<div id='search_box'>
<form method='get' action='search.php'>
<input type='text' placeholder='Search description, tags and Corkboard category' name='q' /><input type='submit' value='Search' />
</form>
</div>
</div>
</div>
</body>
</html>
<?php
} else { ?>
<html>
<head>
<link rel="stylesheet" href="styles/style.css" />
<title>login page</title>
</head>
<body>
<div id='glob_container'>
<div id='header'>
<h1>Login</h1>
<p style='color:red'><strong>Username or Password incorrect!</strong></p>
<form action='home.php' method='post'>
<table width="273" height="111" border="0" align="center">
<tr>
<td width="87">E-mail:</td>
<td width="176"><input name='uname' type='text' id='uname_box' /></td>
</tr>
<tr>
<td>Pin:</td>
<td><input name='pin' type='password' id='pin_box' /></td>
</tr>
<tr>
<td> </td>
<td><input name='sub' type='submit' value='submit' id=='sub_btn' /></td>
</tr>
</table>
</form>
<p> </p>
</div>
<div id='login_box'>
<p> </p>
<p> </p>
</div>
</div>
</body>
</html>
<?php
}
?>