-
Notifications
You must be signed in to change notification settings - Fork 1
/
delete_account.php
executable file
·39 lines (39 loc) · 1.17 KB
/
delete_account.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<?php
session_start();
require 'connections/connection2.php';
require 'security/security1.php';
if(!isset($_REQUEST['id_account'])) {
header("location:logout.php");
}
echo $_SESSION['user_id'];echo "<br>";
echo $_REQUEST['id_account'];echo "<br>";
$stmt = $con2->prepare("SELECT id_account,screen_name FROM accounts WHERE id_account=? AND user_id=? ;");
$stmt->bind_param('si', $_REQUEST['id_account'], $_SESSION['user_id']);
$stmt->execute();
$stmt->bind_result($id_account,$screen_name);
$stmt->store_result();
echo $stmt->num_rows;
if($stmt->num_rows == 1) //To check if the row exists
{
if($stmt->fetch()) //fetching the contents of the row
{
mysqli_query($con2,"delete from accounts where id_account=".$_REQUEST['id_account']."");
echo "<script type=\"text/javascript\"> myerror(); </script>";
$con2->commit();
header("location:cuentas.php");
}
}else {
header("location:logout.php");
}
?>
<html>
<head>
<title>Eliminar Cuenta</title>
<script>
function myerror() {
alert("Borrado correctamente...");
}
</script>
</head>
</html>
</html>