-
Notifications
You must be signed in to change notification settings - Fork 1
/
comment.php
50 lines (43 loc) · 1.43 KB
/
comment.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
<?php
require_once("inc/controller.php");
if(!$session->is_logged_in()){
redirect_to("timeline.php");
}
if(isset($_POST["comment"])){
$body = $_POST["comment"];
$time = date("d-m-Y");
$user_id = $session->user_id;
$log_id = $_POST["log_id"];
$comment = new Comment();
$comment->body = $body;
$comment->time = $time;
$comment->user_id = $user_id;
$comment->log_id = $log_id;
$comment->create();
$_SESSION["message"] = "You just commented! positive";
if($_POST["from_page"] == "profile"){
redirect_to("profile.php?user_id={$_POST["user_id"]}&log_id_commented_on={$comment->log_id}");
} elseif($_POST["from_page"] == "search"){
redirect_to("search.php?query={$_POST["query"]}&log_id_commented_on={$comment->log_id}");
} elseif($_POST["from_page"] == "timeline"){
redirect_to("timeline.php?log_id_commented_on={$comment->log_id}");
}
/* validation of input
if($user->input_validates($username, $email, $password, $password_repeat)){
$user->username = $username;
$user->email = $email;
$user->password = $password;
$user->create();
$_SESSION["message"] = "Welcome on board! positive";
redirect_to("index.php");
} else {
// $_SESSION["message"] gets set by the input_validates method
// so no need to set here
redirect_to("index.php");
}
*/
} else { // form has not been submitted
$_SESSION["message"] = "Something went wrong! negative";
redirect_to("index.php");
}
?>