function getid () {
global $ conn; $ username = $ _ SESSION ['username'];
$ result = $ conn-> prepare ('SELECT * FROM tbl_users WHERE username =?'); $ Result-> bindValue (1, $ имя пользователя); $ result-> execute ();
if ($ result-> rowCount ()> = 1) {$ row = $ result-> fetchAll (PDO :: FETCH_ASSO C); foreach ($ row как $ value) {return $ id = $ value ['id'];
}
}
}
function addrequest () {
global $conn;
global $id;
if (isset ($ _ POST ['btn_send_request'])) {
$result=$conn->prepare('INSERT INTO tbl_request SET country=?,state=?,city=?,first_name=?,last_name=?,username=?,email=?,address=?,file=?,description=?,user_id=?');
$result->bindValue(1,$_POST['country']);
$result->bindValue(2,$_POST['state']);
$result->bindValue(3,$_POST['city']);
$result->bindValue(4,$_POST['first_name']);
$result->bindValue(5,$_POST['last_name']);
$result->bindValue(6,$_POST['username']);
$result->bindValue(7,$_POST['email']);
$result->bindValue(8,$_POST['address']);
$ file = $ _FILES ['file'];
$_1 = explode('.', $file['name']);
$_2 = end($_1);
if (end($file) < 1000000) {
if (in_array($_2, ['jpg', 'jpeg', 'pdf', 'dwg','png'])) {
$name = 'img-' . rand(1, 6000) . '.' . $_2;
move_uploaded_file($file['tmp_name'], 'panel/admin/cms/storage/' . $name);
$result->bindValue(9,$name);
}
} else {
header('location:send_request.php');
}
$ result-> bindValue (10, $ _ POST ['description']);
$result->bindValue(11,$id);
$result->execute();
header('location:send_request.php?addrequest=ok');