Member Avatar for Dainis_1
Dainis_1
<?php 
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);

    session_start();
if (isset($_POST['delete_account'])){

    require  'conn.php';
    global $conn;

    $password = $_POST['delete_password'];
    $email = 'delete@gmail.com';
    $user_id = '5';

    $sql = "SELECT * FROM user_acounts WHERE e_pasts=?;";
    $stmt = mysqli_stmt_init($conn); // Inicializācija 

    if(!mysqli_stmt_prepare($stmt, $sql)){
     header ('location: userpanel.php?error');
     exit();   
     }else{
        mysqli_stmt_bind_param($stmt, "s", $email);
        mysqli_stmt_execute($stmt);
        $result = mysqli_stmt_get_result($stmt);

     }
     if ($row = mysqli_fetch_assoc($result)){

        $password_check = password_verify($password, $row["PAROLE"]);      
        if ($password_check == false){  

          header ('location:userpanel.php?password=false');
          exit();

        }else if ($password_check == true){  

            $SQL = "DELETE FROM user_acounts WHERE e_pasts=?;";
            $stmt = mysqli_stmt_init($conn);

            if (!mysqli_stmt_prepare($stmt, $sql))
                    {
                        header('location: userpanel.php?error');
                        exit();
                    }
                    else
                    {

                        mysqli_stmt_bind_param($stmt, "s", $email);
                        mysqli_stmt_execute($stmt);
                        header('location: userpanel.php?delete=true');
                        exit();
                    }
          }
     }

     mysqli_stmt_close($stmt);
     mysqli_close($conn);

}

?>

I am making a thing that user can delete his account so evrebody works except delete form...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.