-
Notifications
You must be signed in to change notification settings - Fork 0
/
process-form.php
64 lines (37 loc) · 1.13 KB
/
process-form.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
<?php
require_once 'logger.php';
$name = $_POST["name"];
$message = $_POST["message"];
$priority = filter_input(INPUT_POST, "priority", FILTER_VALIDATE_INT);
$type = filter_input(INPUT_POST, "type", FILTER_VALIDATE_INT);
$terms = filter_input(INPUT_POST,"terms", FILTER_VALIDATE_BOOLEAN);
var_dump($name, $message, $priority, $type, $terms);
if ( ! $terms) {
die("Please click agree");
}
$host = "localhost";
$dbname = "mydb";
$username = "root";
$password = "";
$conn = mysqli_connect($host, $username, $password, $dbname);
if (mysqli_connect_errno()) {
die("Connection error: " . mysqli_connect_error());
}
$sql = "INSERT INTO message (name, body, priority, type)
VALUES (?, ?, ?, ?)";
$stmt = mysqli_stmt_init($conn);
if ( ! mysqli_stmt_prepare($stmt, $sql)) {
die(mysqli_error($conn));
}
mysqli_stmt_bind_param($stmt, "ssii",
$name,
$message,
$priority,
$type);
mysqli_stmt_execute($stmt);
echo "Saved!";
/* VULNERABLE TO SQLI
$sql = "INSERT INTO message (name, body, priority, type)
VALUES ('$name', '$message', '$priority', '$type')";
*/
//echo ("Connection established.");