Answer the question
In order to leave comments, you need to log in
How to delete an account at the request of the user?
Good afternoon!
I am writing a graduation project and I have a task: in the personal account, the user can delete his account.
I've already read enough forums and did not find a solution. There is a connection to the database, the data is entered, I tried to write different queries - it did not work out. I enclose the code:
Index.php file:
<p> Привет, <?=$_COOKIE['user']?>! </p>
<form action="join_chat.php" method="post">
<button class="btn btn-success" type="submit"> Чтобы войти в чат нажмите здесь </button>
</form>
<br>
<form action="exit.php" method="post">
<button class="btn btn-warning" type="submit"> Чтобы выйти нажмите здесь </button>
</form>
<br>
<form action="delete_account.php" method="post">
<button class="btn btn-danger" type="submit"> Чтобы удалить аккаунт нажмите здесь </button>
</form>
<?php
$id = filter_var(trim($_POST['id']),
FILTER_SANITIZE_STRING);
$login = filter_var(trim($_POST['login']),
FILTER_SANITIZE_STRING);
$name = filter_var(trim($_POST['name']),
FILTER_SANITIZE_STRING);
$pass = filter_var(trim($_POST['pass']),
FILTER_SANITIZE_STRING);
$root_id = filter_var(trim($_POST['root_id']),
FILTER_SANITIZE_STRING);
$root_name = filter_var(trim($_POST['root_name']),
FILTER_SANITIZE_STRING);
$mysql = new mysqli('localhost', 'root', 'root', 'diplom');
$mysql->query("DELETE FROM `username` WHERE `id` = '$id'");
$mysql->close();
header('Location: /');
?>
Answer the question
In order to leave comments, you need to log in
<form action="delete_account.php" method="post">
<button class="btn btn-danger" type="submit"> Чтобы удалить аккаунт нажмите здесь </button>
</form>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question