-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsave_feedback.php
More file actions
76 lines (60 loc) · 1.86 KB
/
Copy pathsave_feedback.php
File metadata and controls
76 lines (60 loc) · 1.86 KB
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
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="initial-scale=1.0, user-scalable=no, minimal-ui"/>
</head>
<body>
<?php
$stationid = htmlspecialchars($_POST["stationid"]);
$reason = htmlspecialchars($_POST["reason"]);
$comment = htmlspecialchars($_POST["comment"]);
function db_connect()
{
// Zugangsdaten für die DB
$dbhost = 'localhost';
$dbuser = 'esfinder';
$dbpass = 'esfinder2000';
$dbname = 'esfinder';
// Verbindung herstellen und Verbindungskennung zurück geben
$conid = mysql_connect( $dbhost, $dbuser, $dbpass ) or die( 'Verbindungsfehler!' );
if (is_resource( $conid ))
{
mysql_select_db( $dbname, $conid ) or die( 'Datenbankfehler!' );
}
return $conid;
}
// Datenbankverbindung öffnen
$conid = db_connect();
// Neues Datenbank-Objekt erzeugen
$db = @new mysqli( 'localhost', 'esfinder', 'esfinder2000', 'esfinder' );
// Pruefen ob die Datenbankverbindung hergestellt werden konnte
if (mysqli_connect_errno() == 0)
{
/*
* Hier wird Code ausgefuehrt, wenn die Datenbankverbindung
* fehlerfrei hergestellt werden konnte.
*/
// Eintragen speichern
if (isset( $_POST['action'] ) AND $_POST['action'] == 'save')
{
$sql = 'INSERT INTO `diemo_feedback` (`stationid`, `reason`, `comment`) VALUES (?, ?, ?)';
$eintrag = $db->prepare( $sql );
// Variablen an die Anweisung binden
$eintrag->bind_param( 'sss', $stationid, $reason, $comment);
// Update ausfuehren
$eintrag->execute();
$eintrag->close();
echo 'Feedback gespeichert';
}
}
else
{
// Es konnte keine Datenbankverbindung aufgebaut werden
echo 'Die Datenbank konnte nicht erreicht werden. Folgender Fehler trat auf: <span class="hinweis">' .mysqli_connect_errno(). ' : ' .mysqli_connect_error(). '</span>';
}
// Datenbankverbindung schliessen
$db->close();
?>
</body>
</html>