-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
213 lines (157 loc) · 8.04 KB
/
index.php
File metadata and controls
213 lines (157 loc) · 8.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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
<!--Roxanne Low -->
<!--COM 214 Final Project -->
<!--Spring 2017-->
<html>
<head>
<br><br>
<link rel="stylesheet" href="main.css">
<link rel=icon href="logo.svg"/>
<a href="index.php"> <img src="logo.png" style="width: 250px; height:250px;margin:auto; display:block"></a>
<title> U.N.I.T.E.D </title>
<h1 id="title"> U.N.I.T.E.D. </h1>
<h2 id="titlecap"> U n I Together Embracing Diversity </h2>
<br><br><br>
<script>
function load(){
var nitem = document.getElementById("optionsItem") ;
var activity = document.getElementById("optionsActivity") ;
if(localStorage.getItem("checkbox1")!=undefined){
nitem.value = localStorage.getItem("checkbox1");
}
else{
nitem.value =5;
}
if(localStorage.getItem("checkbox2")!=undefined){
activity.value = localStorage.getItem("checkbox2");
}
else{
activity.value =7;
}
}
//Saves the dropdown menu values as local storage
function save(){
var check = document.getElementById("optionsItem");
console.log(check.value);
localStorage.setItem("checkbox1", check.value);
}
function saveact(){
var check = document.getElementById("optionsActivity");
console.log(check.value);
localStorage.setItem("checkbox2", check.value);
}
</script>
</head>
<body onload ="load()">
<p>
<a href="login.php">Login/Signup</a>
<a href="contact.html">Contact </a>
<a href="documentation.html">Documentation</a> </p>
<br> <br>
<h1 id="connect"> Connect with Your Community</h1>
<form id="content" method="get" action="index.php">
<form>
Items per page
<select id="optionsItem" name="items" type ="submit" onchange = "save()">
<option value="5" selected>5</option>
<option value="10">10</option>
<option value="15">15</option>
<option value="20">20</option>
</select>
Activity
<select id="optionsActivity" name="activity" type ="submit" onchange = "saveact()">
<option value="1" selected>Have a meal</option>
<option value="2">Play sports</option>
<option value="3">Do art</option>
<option value="4">Play music</option>
<option value="5">Read books</option>
<option value="6">Learn languages</option>
<option value="7">Celebrate holiday </option>
</select> <br><br><br>
<input id="getNLButt" <a href = "connect" type="submit" name="NL-button" value="New London">
</div>
</form>
<br>
<form>
<article id="output"></article>
<?php
$activities= array('Meal', 'Sports', 'Art', 'Music', 'Books', 'Languages', 'Celebration');
list($a[1],$a[2],$a[3],$a[4],$a[5],$a[6],$a[7]) =$activities;
// --- CREATE THE DATABASE
$db_conn = mysqli_connect("localhost", "root", "");
if (!$db_conn)
die("Unable to connect: " . mysqli_connect_error());
if (isset($_GET['NL-button'])) {
mysqli_query($db_conn, "CREATE DATABASE IF NOT EXISTS newlondonDB;");
mysqli_select_db($db_conn, "newlondonDB");
$cmd = "CREATE TABLE IF NOT EXISTS users (
id int(11) PRIMARY KEY NOT NULL AUTO_INCREMENT,
username varchar(60) UNIQUE NOT NULL,
password varchar(60) NOT NULL,
email varchar(60) NOT NULL,
telephone int(15) NOT NULL
);";
$cmd1 = "CREATE TABLE IF NOT EXISTS actionlist( id int(11) PRIMARY KEY NOT NULL AUTO_INCREMENT,
date varchar (12) NOT NULL,
name varchar(35) NOT NULL,
email varchar(35) NOT NULL,
title varchar(20) NOT NULL,
des mediumtext DEFAULT NULL,
tag varchar(35) NOT NULL
);";
/*
if( mysqli_query($db_conn, $cmd) && mysqli_query($db_conn, $cmd1) )
echo "Tables 'users' and 'actionlist' created<br>";
else
echo "Tables not created: ". mysqli_error($db_conn) . "<br>";
*/
mysqli_query ($db_conn, $cmd);
mysqli_query ($db_conn, $cmd1);
$cmd= "LOAD DATA LOCAL INFILE 'users.csv' INTO TABLE users FIELDS TERMINATED BY ','";
$cmd1 = "LOAD DATA LOCAL INFILE 'actions.csv' INTO TABLE actionlist FIELDS TERMINATED BY ','"; //Loads into the actual csv file
mysqli_query ($db_conn, $cmd);
mysqli_query ($db_conn, $cmd1);
//$name = $_GET['posx']; //gets the value in the input forms, and sets it as the variable
//$clickLat = $_GET['posy'];
$tag = $_GET['activity'];
$nItems= $_GET['items'];
//Order sent to MySQL so that it sorts from longitude and latitude, and asks for the number of items
$cmd1 = "SELECT*
FROM actionlist
WHERE tag='".$tag."'
ORDER BY date DESC
LIMIT $nItems;";
$records = mysqli_query($db_conn, $cmd1);
//populates the table
echo "<div id ='post'>".PHP_EOL;
while($row = mysqli_fetch_array($records)){
echo( "<p id='username'> Name: " .$row['name'] . "</p> <p id='contact'> Contact: " .$row['email']. "<p id='date'> Date Posted: ".$row['date']. "</p> <p id='tag'> Category: ".$a[$row['tag']]. "</p>" .PHP_EOL);
echo("</p><p id='posttitle'>" .$row['title']."</p> <p id='description'>" .$row['des']. "</p>" .PHP_EOL );
echo "<p> --------------------------------------------------------------------------------------------------------------- </p>".PHP_EOL;
}
}
echo " </div>".PHP_EOL;
mysqli_close($db_conn);
?>
</form>
<br><br>
<br><br>
<video width="700" height="500" controls loop >
<source src="diversity.mp4" type="video/mp4">
Your browser does not support the video tag.
</video>
<br><br>
<br><br>
<h2>Mission</h2>
<div>
<p>
The mission of this site is to promote cultural awareness and understanding.
<br> There is a strong power within a group of community members working together. This site aims to bridge the gap and build strong relationships through culture exchange activities. </p>
</div>
<h2>Work</h2>
<div>
<p> This site provides a platform where community members can connect with other on various levels.<p>
</div>
<br><br><br>
</body>
</html>