-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprofile.php
212 lines (159 loc) · 7.48 KB
/
profile.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
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
<?php
include('session.php');
if(!isset($_SESSION['login_user'])){
header("location: account_creation.php");
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<script src="lorem.js"></script>
<script src ="file.js"></script>
<link rel="stylesheet" href="upload.css">
<link rel="stylesheet" href="main.css">
<title>Writely</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial scale=1.0">
</head>
<body>
<div id="page-container">
<div id="content-wrap">
<header>
<div id="logo">Writely</div>
<nav>
<ul class="nav__links">
<li><a href="Project.php">Home</a></li>
<li><a href="profile.php">Profile</a></li>
<li><a href="writing.php">Upload</a></li>
<li><a> Welcome, <?php echo $login_session; ?></a></li>
<li><a href= "logout.php"> Logout</a></li>
</ul>
</nav>
<form action="searchresults.php" method="post">
<input type="text" name="search" placeholder="Search posts">
<input type="submit" value="Go">
</form>
</header>
<script type="text/javascript" src="mobile.js"></script>
<!--<h1>Jerry Garcia</h1>-->
<div class="side_bar">
<p><Strong><?php echo $login_session; ?></Strong></p>
<main class="uploadmain">
<button id='headerbtn'>Add bio</button>
<div id="editor" contenteditable="true" data-text="Enter text here..." required></div>
<!--scripts to handle the text formatting buttons-->
<script>
$(document).ready(function(){
$("#editor").hide();
$(".uploadtable").hide();
$("#submitbtn").hide();
$("#fileupload").hide();
$('#headerbtn').on('click', function(){
$(".uploadtable").fadeToggle(100);
$("#editor").fadeToggle(100);
$("#submitbtn").fadeToggle(100);
$("#uploadbtn").fadeToggle(100);
$(".uploadwrapper, .uploadwrapper2").toggleClass("uploadwrapper uploadwrapper2");
})
$("#uploadbtn").on('click', function(){
$("#fileupload").fadeToggle(300);
$("#headerbtn").fadeToggle(300);
$("#submitbtn").fadeToggle(300);
})
//buttons for text editor
$('#boldbtn').on('click', function(){
$('#editor').focus();
document.execCommand('bold');
$(this).toggleClass("gray");
});
$('#italicbtn').on('click', function(){
$('#editor').focus();
document.execCommand('italic');
$(this).toggleClass("gray");
});
$('#underbtn').on('click', function(){
$('#editor').focus();
document.execCommand('underline');
$(this).toggleClass("gray");
});
$("#fs").change(function(){
$('#editor').css("font-family", $(this).val());
$('#editor').focus();
});
$("#size").change(function(){
$('#editor').css("font-size", $(this).val() + "px");
$('#editor').focus();
});
$("#submitbtn").click(function(){
var writing = $("#editor").html();
sessionStorage.setItem("writing", writing);
$(document).ready(function(){
$("#content").val(writing);
});
if(writing == ""){
alert("Text box cannot be blank");
return false;
}
});
});
</script>
</main>
</div>
<div class="post">
<?php
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "upload";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "SELECT id, content, Title, Publicity FROM post";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
// output data of each row
while($row = $result->fetch_assoc()) {
if($row["Publicity"] != 0){
echo "<div class='post'><img img src='Generic-Profile.png' alt='profile' height= 20px; width=20px;><b> John Doe:</b><br><br><i>". $row["Title"]. ":</i> <br>". $row["content"]. "</div>" ;
}
}
} else {
echo "0 results";
}
$conn->close();
?>
</div>
<div style="text-align: center;">
<?php
$id = isset($_GET['content']) ? $_GET['content'] : '';
$host = "localhost";
$dbUsername = "root";
$dbPassword = "";
$dbname = "bio";
//create connection
$conn = new mysqli($host, $dbUsername, $dbPassword, $dbname);
if (mysqli_connect_error()) {
die('Connect Error('. mysqli_connect_errno().')'. mysqli_connect_error());
}
else {
$insert = "INSERT Into bio (content) VALUES ('$content')";
//Prepare statement
$stmt = $conn->prepare($insert);
$stmt->bind_param("s", $content);
$stmt->execute();
echo "New record created successfully";
}
die();
?>
</div>
<div class="end_footer">
Contact us!<br>
Send us an <a href= "mailto:[email protected]">e-mail!</a><br>
<small><i>Copyright © 2020 Writely</i></small><br> </div>
</div>
</div>
</body>
</html>