What is the error code?

Notice: Undefined variable: id in D:\OSPanel\domains\localhost\3\reg\user.php on line 5

Notice: Undefined variable: username in D:\OSPanel\domains\localhost\3\reg\user.php on line 5

Notice: Undefined variable: email in D:\OSPanel\domains\localhost\3\reg\user.php on line 5

Notice: Undefined variable: password in D:\OSPanel\domains\localhost\3\reg\user.php on line 5

Notice: Undefined variable: ban in D:\OSPanel\domains\localhost\3\reg\user.php on line 5
Here are the errors:

Notice: Undefined variable: role in D:\OSPanel\domains\localhost\3\reg\user.php on line 5

Warning: mysqli_connect(): (HY000/1045): Access denied for user "@'localhost' (using password: NO) in D:\OSPanel\domains\localhost\3\reg\user.php on line 5

Fatal error: Uncaught Error: Call to undefined function myswli_query() in D:\OSPanel\domains\localhost\3\reg\user.php:6 Stack trace: #0 {main} thrown in D:\OSPanel\domains\localhost\3\reg\user.php on line 6


Here is the code:
<?php
error_reporting(E_ALL);
ini_set('display_errors','on');

 $link = mysqli_connect($id, $username, $email, $password, $ban, $role);
 myswli_query($link, "SET NAMES 'utf8'");

 if (isset($_GET['del'])){
 $id = $_GET['del'];

 $query = "DELETE FROM user WHERE id=$id";
 mysqli_query($link, $query) or die (mysqli_error($link));
}

 $query = "SELECT * FROM user";
 $result = mysqli_query($link, $query) or die (mysqli_error($link));

 for ($data = []; $row = mysqli_fetch_assoc($result); $data[] = $row);

?>


<!DOCTYPE html>
<html lang="en">
the <head>
 <meta charset="utf-8">
 <meta name="viewport"
 content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
 <meta http-equiv="X-UA-Compatible" content="ie=edge">
 <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" by adding crossorigin="anonymous">
 <link rel="stylesheet" href="style.css">
<title>Authorize</title>
</head>
the <body>

<table>
<?php foreach ($data as $user) { ?>
the <tr>
 <td><?= $user['id'] ?></td>
 <td><?= $user['username'] ?></td>
 <td><a href="?del=<?= $user['id'] ?>">delete</a></td>
</tr>
<?php }?>
</table>

}

</body>
</html>
April 19th 20 at 12:10
2 answers
April 19th 20 at 12:12
myswli_query() replace mysqli_query()
Yes, I already corrected. Thank you) - Felicia81 commented on April 19th 20 at 12:15
@Felicia81, don't forget to click like and mark solution - harrison.Hoppe commented on April 19th 20 at 12:18
@harrison.Hoppecan help with other errors?
Here is the code:
<?


if ($_POST['edit_f']) {
 $id = array_pop($_POST);
 if (!is_numeric($id))
 message('user ID is incorrect');
 $_SESSION['edit_id'] = $id;
go('a_edit');
}

else if ($_POST['save_f']) {
 if (!is_numeric($_POST['username']))
 message('user Name incorrect');
 else if (!is_numeric($_POST['email']))
 message('E-mail is incorrect');
 else if (!is_numeric($_POST['password']))
 message('Password is incorrect');
 else if ($_POST['ban'] != 1 and $_POST['ban'] != 0)
 message('invalid Lock');

valid_wallet();
valid_name();
 mysqli_query($localhost, "UPDATE `users` SET `email` = $_POST[email], `password` = $_POST[password] `ban` = $_POST[ban], `username` = '$_POST[username]' WHERE `id` = $_SESSION[edit_id]");
message('Saved');
}



$row = mysqli_fetch_assoc(mysqli_query($localhost, "SELECT * FROM `users` WHERE `id` = $_SESSION[edit_id]"));


('Editor user') ?>


<div class="form">
<h1><?=$row['username']?></h1>
 <p>user Name</p>
 <p><input type="text" id="username" value="<?=$row['username']?>"></p>
<p>Email</p>
 <p><input type="text" id="email" value="<?=$row['email']?>"></p>
<p>Password</p>
 <p><input type="text" id="password" value="<?=$row['password']?>"></p>
<p>the Role</p>
 <p><input type="text" id="role" value="<?=$row['role']?>"></p>
<p>Blocked</p>
 <p><select id="ban"><?=str_replace('value="'.$row['ban'].'"', 'value="'.$row['ban'].'" selected', '<option value="0">No</option><option value="1">Yes</option>')?></select></p>

 <p><button onclick="send_post('a_edit', 'save', 'username.email.password.ban')">Save</button></p>
</div>


Here are the errors:
5e97739854466521509201.png - Felicia81 commented on April 19th 20 at 12:21
@Felicia81, in another question, write - harrison.Hoppe commented on April 19th 20 at 12:24
April 19th 20 at 12:14
first, the variables are taken from the air.
They need to be defined prior to use.

In the second
$link = mysqli_connect($id, $username, $email, $password, $ban, $role);
read the description of this function.
Please note that it takes in as parameters.

Connection settings usually endure in a separate file . And announced through constants.
Read about include requiery and their variants include_once ...

Having mastered the basic work with databases in functional style, take a look at ready classes wrappers.
Approaches active record, doctrine, etc.

But first still basics . and then pdo is already an abstraction.

Find more questions by tags PHP