-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathuploadReview.php
89 lines (78 loc) · 1.81 KB
/
uploadReview.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
<?php
include 'db_helper.php';
//Prompt user to log in
session_start();
while(!isset($_SESSION['username'])){
echo ("<script LANGUAGE='JavaScript'>
window.alert('Please log in to create a topic');
window.location.href='loginregister.php';
</script>");
exit();
}
$username = $_SESSION['username'];
if (isset($_POST['submit']))
{
$dbc = OpenCon();
$errors = array();
if (!empty($_POST['message']))
{
$feedback = $_POST['message'];
}
else
{
$errors = "nofeedback";
}
if (!empty($_POST['rating']))
{
$rating = $_POST['rating'];
}
else
{
$errors = "norating";
}
if (empty($errors))
{
$r = insertFeedback($username, $feedback, $rating, $dbc);
if ($r)
{
header ("Location: contact.php?status=success");
CloseCon($dbc);
exit();
}
else
{
header ("Location: contact.php?status=failed");
CloseCon($dbc);
exit();
}
}
else
{
$i = 0;
$headerMsg = "Location: listPost.php?";
while ($i < sizeof(errors))
{
if (i == 0)
{
$headerMsg = $headerMsg . "error" . $i . "=" . $errors[$i];
}
else if (i > 0)
{
$headerMsg = $headerMsg . "&error" . $i . "=" . $errors[$i];
}
$i++;
}
header ($headerMsg);
CloseCon($dbc);
exit();
}
}
else
{
header ("Location: contact.php?hi=hi");
exit();
}
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/Scripting/EmptyPHP.php to edit this template
*/