-
Notifications
You must be signed in to change notification settings - Fork 0
/
comment.php
50 lines (37 loc) · 1.1 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
//ini_set('session.save_path', '/nfs/stak/students/o/ohaverd/session');
session_start();
$host = 'oniddb.cws.oregonstate.edu';
$db = 'ohaverd-db';
$user = 'ohaverd-db';
$pw = 'delete';
$mysqli = new mysqli($host, $user, $pw, $db);
if ($mysqli->connect_errno) {
echo 'Failed to connect to MySQLi: (' . $mysqli->connect_errno . ') ' . $mysqli->connect_error;
}
$cartname = $_SESSION['username'];
$comment = $_POST['comment'];
$where = $_POST['wherefrom'];
$addcomment = $mysqli->prepare("INSERT INTO comments (user, name, comment) VALUES (?, ?, ?)");
if (!$addcomment) {
echo 'Addcomment prepare fail';
}
$addcomment->bind_param('sss', $cartname, $where, $comment);
$addcomment->execute();
$addcomment->close();
if ($where == 'orange') {
header('LOCATION: orange.php');
}
if ($where == 'swirl') {
header('LOCATION: swirl.php');
}
if ($where == 'butterfly') {
header('LOCATION: butterfly.php');
}
if ($where == 'antique') {
header('LOCATION: antique.php');
}
if ($where == 'church') {
header('LOCATION: church.php');
}
?>