-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsg_process.php
More file actions
36 lines (32 loc) · 985 Bytes
/
sg_process.php
File metadata and controls
36 lines (32 loc) · 985 Bytes
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
<?php
require_once('includes/autoload.php');
if (isset($_POST['e'])) {
$n = trim(mysqli_real_escape_string($con, $_POST['n']));
$e = trim(mysqli_real_escape_string($con, $_POST['e']));
$p = trim(mysqli_real_escape_string($con, $_POST['p']));
$t = trim(mysqli_real_escape_string($con, $_POST['t']));
if ($n == '' || $e == '' || $p == '' || $t == '') {
echo 'failed first';
exit();
} else if (strlen($n) > 50 || strlen($p) > 10 || strlen($t) > 500 || strlen($t) < 30) {
echo 'Failed';
exit();
} else {
$now = time();
$ip = preg_replace("#[^0-9.]#", "", getenv('REMOTE_ADDR'));
$sql = "INSERT INTO suggestions (name, phone, email, content, submit_date, ip)";
$sql .= " VALUES ('{$n}', '{$p}', '{$e}', '{$t}', '{$now}', '{$ip}')";
$result = mysqli_query($con, $sql);
if (!$result) {
echo 'Failed';
exit();
} else {
echo 'success';
exit();
}
}
} else {
header('Location: suggestion.php');
exit();
}
?>