-
Notifications
You must be signed in to change notification settings - Fork 0
/
save-as-engine.php
46 lines (24 loc) · 1.34 KB
/
save-as-engine.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
<?php
if((isset($_COOKIE['log-id-cookie'])) && $_COOKIE['log-statue-cookie'] == 1) {
$id = $_COOKIE['log-id-cookie'];
$jGraph = $_POST['graph'];
$title = $_POST['title'];
$id = mb_convert_encoding ( $id, "UTF-8",mb_detect_encoding($id));
$jGraph = mb_convert_encoding ( $jGraph, "UTF-8",mb_detect_encoding($jGraph));
$title = mb_convert_encoding ( $title, "UTF-8",mb_detect_encoding($title));
$mysqli= new mysqli('magic.philosophy.ubc.ca', 'root', 'PhiloMagic2015!', 'whately');
// check connection
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
$stmt1 = $mysqli -> prepare("SET character_set_results = 'utf8', character_set_client = 'utf8', character_set_connection = 'utf8', character_set_database = 'utf8', character_set_server = 'utf8'");
$stmt1 -> execute();
$stmt = $mysqli -> prepare("INSERT INTO `graph`(`id`, `graph`, `title`) VALUES (?, ?, ?)");
$stmt -> bind_param('sss', $id, $jGraph, $title);
$stmt -> execute();
$stmt->close();
setcookie('saved-as-graph-cookie', 1);
echo "<script>window.location.href='http://magic.philosophy.ubc.ca/argumentMapping/graph.php';</script>";
}
?>