$dbi = new PDO("mysql:dbname=$nameofdbi;host=$hosti", $dbusernamei, $dbpasswordi, array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8"));
$a = $_POST['lol'];
$query = "INSERT INTO `usr`.`rtm` (`lol`) VALUES (?)";
$stmt = $dbi->prepare($query);
$stmt->bindParam(1, $a, PDO::PARAM_STR);
$stmt->execute();
$url_google_api = 'https://www.google.com/recaptcha/api/siteverify';
$google_query = $url_google_api . '?secret=' . RECAPTHA_PRIVATE_KEY . '&response=' . $this->request->getPost('g_token') . '&remoteip=' . $_SERVER['REMOTE_ADDR'];
$google_data = json_decode(file_get_contents($google_query));
$valid_formats = [
'jpg',
'jpeg',
'png',
'gif',
'bmp'
];
$ext = pathinfo($_FILES['filename']['name'], PATHINFO_EXTENSION);
if (!isset($valid_formats[$ext])) {
return 'error';
}
$filename = md5($_FILES['filename']['name'].uniqid()). '.' .$ext;
if (!is_file('upload/'.$filename)) {
move_uploaded_file($_FILES['filename']['tmp_name'], 'upload/'.$filename);
}