-
Notifications
You must be signed in to change notification settings - Fork 0
/
comment_collect.php
69 lines (54 loc) · 2.41 KB
/
comment_collect.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
<?php
include('database_connect.php');
include('autoinc.php'); //including the file containing the function to auto increment the comment id (eg: C_1)
session_start();
$userId = $_SESSION["userid"];
$description = $_POST["description"];
$commentType = $_POST["commentType"];
$submissionId = $_POST["subId"];
$d =date_default_timezone_set("Asia/Colombo");
$dateValue = date("y-m-d H:i:s");
//$timeValue = date("H:i:s");
//$dateinString = date_format($today,"Y-m-d");
//echo $commentType."<br />".$description."<br />".$submission;
$val = "Comment";
$commentId = autoIncrementIds($val);
$isComment = strcmp($commentType,"Add a comment");
if ($isComment == 0)
{
$currentMonth=date("m");
//That means this is a comment. Therefore add to the comment table
$sqlInsertComment = "INSERT INTO comment(commentId,submissionId,userId,description,date,commentType,monthOf) VALUES('$commentId','$submissionId','$userId','$description','$dateValue','Comment', '$currentMonth')";
if(mysqli_query($con,$sqlInsertComment))
{
/*echo "<script type='text/javascript' > alert('Thank You. We successfully added your comment') </script>";*/
$submitid =1;
header('location:viewidea.php?id='.$submissionId.'&submitid='.$submitid.'&comt=0');
}
else
{
$submitid =0;
/*echo "<script type='text/javascript' > alert('error : '".mysqli_error($con).") </script>";*/
header('location:viewidea.php?id='.$submissionId.'&submitid='.$submitid.'&comt=0');
}
}
else
{
include('rewardcheck3.php');//That means this is the other option. Which is an improvement. Therefore add to improvement table
$sqlInsertImprovement = "INSERT INTO comment(commentId,submissionId,userId,description,date,commentType) VALUES('$commentId','$submissionId','$userId','$description','$dateValue','Improvement')";
if(mysqli_query($con,$sqlInsertImprovement))
{
/*echo "<script type='text/javascript' > alert('Thank You. We successfully added your Improvement submission')</script>";*/
$submitid =2;
header('location:viewidea.php?id='.$submissionId.'&submitid='.$submitid.'&comt=0');
}
else
{
$submitid =0;
/*echo "<script type='text/javascript' > alert('error : '".mysqli_error($con).") </script>";*/
header('location:viewidea.php?id='.$submissionId.'&submitid='.$submitid.'&comt=0');
}
}
//return $submitid;
mysqli_close($con);
?>