How to do a personal task Board?

There is a to-do sheet with the registration. We need to make sure that each user had their own personal task Board. Could make assignments from the Board was recorded in the database, but do not know how to get them on the page.
P. S: I Know that it is better to work using PDO, but it's easier at the moment...

The dB connection
<?php

 $connect = mysqli_connect('localhost', 'root', ", 'test');

 if (!$connect) {
 die('Error connect to DataBase');
 }


The connection to Check
<?php

session_start();
require_once 'connect.php';

$full_name = $_POST['full_name'];
$login = $_POST['login'];
$email = $_POST['email'];
$password = $_POST['password'];
$password_confirm = $_POST['password_confirm'];

$check_login = mysqli_query($connect, "SELECT * FROM `users` WHERE `login` = '$login'");
if (mysqli_num_rows($check_login) > 0) {
 $response = [
 "status" => false,
 "type" => 1,
 "message" => "This username already exists",
 "fields" => ['login']
];

 echo json_encode($response);
die();
}

$error_fields = [];

if ($login === ") {
 $error_fields[] = 'login';
}

if ($password === ") {
 $error_fields[] = 'password';
}

if ($full_name === ") {
 $error_fields[] = 'full_name';
}

if ($email === " || !filter_var($email, FILTER_VALIDATE_EMAIL)) {
 $error_fields[] = 'email';
}

if ($password_confirm === ") {
 $error_fields[] = 'password_confirm';
}

if (!$_FILES['avatar']) {
 $error_fields[] = 'avatar';
}

if (!empty($error_fields)) {
 $response = [
 "status" => false,
 "type" => 1,
 "message" => "Check the spelling of fields",
 "fields" => $error_fields
];

 echo json_encode($response);

die();
}

if ($password === $password_confirm) {

 $path = 'uploads/' . time() . $_FILES['avatar']['name'];
 if (!move_uploaded_file($_FILES['avatar']['tmp_name'], '../' . $path)) {
 $response = [
 "status" => false,
 "type" => 2,
 "message" => "Error loading avatar",
];
 echo json_encode($response);
}

 $password = md5($password);

 mysqli_query($connect, "INSERT INTO `users` (`id`, `full_name`, `login`, `email`, `password`, `avatar`) VALUES (NULL, '$full_name', '$login', '$email', '$password', '$path')");

 $response = [
 "status" => true,
 "message" => "Registration was successful!",
];
 echo json_encode($response);


} else {
 $response = [
 "status" => false,
 "message" => "the Passwords do not match",
];
 echo json_encode($response);
}

?>


Connection authorization

<?php

session_start();
require_once 'connect.php';

$login = $_POST['login'];
$password = $_POST['password'];

$error_fields = [];

if ($login === ") {
 $error_fields[] = 'login';
}

if ($password === ") {
 $error_fields[] = 'password';
}

if (!empty($error_fields)) {
 $response = [
 "status" => false,
 "type" => 1,
 "message" => "Check the spelling of fields",
 "fields" => $error_fields
];

 echo json_encode($response);

die();
}

$password = md5($password);

$check_user = mysqli_query($connect, "SELECT * FROM `users` WHERE `login` = '$login' AND `password` = '$password'");
if (mysqli_num_rows($check_user) > 0) {

 $user = mysqli_fetch_assoc($check_user);

 $_SESSION['user'] = [
 "id" => $user['id'],
 "full_name" => $user['full_name'],
 "avatar" => $user['avatar'],
 "email" => $user['email']
];

 $response = [
 "status" => true
];

 echo json_encode($response);

} else {

 $response = [
 "status" => false,
 "message" => 'is Not a valid username or password'
];

 echo json_encode($response);
}
?>


The Board itself(profile)
<?php
session_start();
if (!$_SESSION['user']) {
 header('Location: /');
}


?>

<!DOCTYPE html>
<html >
the <head>
 <meta charset="UTF-8">
<title></title>
 <link rel="stylesheet" href="assets/css/mainprof.css">
 <link rel="stylesheet" type="text/css" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css">
</head>
the <body>

 <!-- Profile -->
 <div class="conteiner">


 <img src="<?= $_SESSION['user']['avatar'] ?>" width="200" alt="" class="ava">


 <span class="log"><?= $_SESSION['user']['full_name'] ?></span>
 <div class="menu">
 <a href="#"class="menu-btn">Find user
 <svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" class="mx-3" role="img" viewBox="0 0 24 24" focusable="false"><title>Search</title><circle cx="10.5" cy="10.5" r="7.5"></circle><path d="M21 21l-5.2-5.2"></path></svg></a>
 <a href="#"class="menu-btn">Available boards</a>
 <a href="vendor/logout.php" class="logout">Logout</a>
</div>

</div>

</div>

The connection to the Board 
<code lang="php">
<?php

session_start();
require_once 'connect.php';

$task = $_GET['task'];
if ($task =="){
 echo 'Enter text';
exit();
}

 mysqli_query($connect, "INSERT INTO `mydata` (`id`, `task`) VALUES (NULL, '$task')");
header('Location:../profile.php')


?>
</code>

<!--Board-->
<div class="conteiner2">

 <div class="to-do">
 <form action="vendor/addtodo.php" method="GET">
 <input type="text" name="task" placeholder="Enter text!">
 <button type="submit"class="dob">Add </button>

</form>
 <!--<div class="problem">
 Some text
</div>-->



</div>
</div>



</body>
</html>


DB table user5e9751d573605936289214.png
Database table mydata 5e9751e628efc066397304.png
April 19th 20 at 12:12
2 answers
April 19th 20 at 12:14
little code
And the code that else to throw? - noemie.Cro commented on April 19th 20 at 12:17
April 19th 20 at 12:16
The withdrawal of all "task" from dB where user id
SELECT `task` FROM `mydata` WHERE `user_id` = ?

$tasks = mysqli_query($connect, "SELECT `task` FROM `mydata` WHERE `user_id` =".$_SESSION['user']['id']);

if (mysqli_num_rows($tasks) > 0) {
 while($user = mysqli_fetch_assoc($result)) {
 echo $result['task'];
}
}

Screen all incoming data and use more modern methods of communication with the database.

Find more questions by tags MySQLPHP