set_include_path(".:/usr/lib/php:/usr/local/lib/php:/var/www/html/assets");
date_default_timezone_set('Europe/Moscow');
require 'test/bd.php';
$time = time();

if(isset($_POST['mode']) && $_POST['mode'] == 'add_phone' && $_POST['phone'])
	mysqli_query($bd, 'INSERT black_list (number, user) VALUES (\'' . $_POST['phone'] . '\', \'' . $user . '\')');

if($_GET['delete_num'])
	mysqli_query($bd, 'DELETE FROM black_list WHERE number = \'' . $_GET['delete_num'] . '\' AND user = \'' . $user . '\'');

$data = mysqli_query($bd, 'SELECT * FROM black_list WHERE user=\'' . $user . '\'');
while($row = mysqli_fetch_assoc($data))
	$numbers[] = $row['number'];
?>
<link rel="stylesheet" type="text/css" href="/assets/components/style_vay.css">

<div class="container_vay">
	<form action="chernyij-spisok" method="POST">
		<input type="hidden" name="mode" value="add_phone">
		<input type="text" name="phone" autocomplete="off" placeholder="Номер телефона">
		<button type="submit">Добавить номер</button>
	</form>
	<hr>
	
	<table class="numbers_list">
		<thead>
			<th style="width:3%;">№</th>
			<th>Телефон</th>
			<th>Изменения</th>
		</thead>
		<tbody>
	<?foreach($numbers as $num):?>
		<tr>
			<td><?=++$i?></td>
			<td><?=$num?></td>
			<td>
				<a href="chernyij-spisok?delete_num=<?=$num?>">Удалить</a>
			</td>
		</tr>
	<?endforeach?>
		</tbody>
	</table>
</div>
<?php