-
Notifications
You must be signed in to change notification settings - Fork 0
/
dbconn.php
29 lines (22 loc) · 816 Bytes
/
dbconn.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
<?php
function sanitize($input) {
// if input is an array, loop through its elements
if (gettype($input) == 'array') {
$returnable_array = array();
foreach ($input as $element) {
$element = strip_tags($element);
array_push($returnable_array, trim(htmlspecialchars($element, ENT_COMPAT, 'UTF-8')));
}
return $returnable_array;
}
// if input is not an array, treat it as a string
$stripped = strip_tags($input);
return trim(htmlspecialchars($stripped, ENT_COMPAT, 'UTF-8'));
}
// removed actual credentials
$host = "not-secure";
$username = "not-secure";
$password = "not-secure";
$db = "not-secure";
$conn = @mysqli_connect($host, $username, $password, $db) or die('Could not connect to MySQL');
mysqli_set_charset($conn, 'utf8');