prepare("SELECT username,user_closed FROM users WHERE email = ? AND password = ?"); $stmt->bind_param("ss", $email, $pass); // "ss" indicates two string parameters $stmt->execute(); $stmt->bind_result($username,$closed); $stmt->fetch(); if ($username != null) { $_SESSION['username'] = $username; if ($closed === 0) { // Reopens account if the account was closed. $stmt = $con->prepare("UPDATE users SET user_closed = '0' WHERE email = ?"); $stmt->bind_param("s", $email); // Bind parameters for security $stmt->execute(); $stmt->close(); // Close the statement for proper resource management } header("Location: index.php"); exit(); } else { array_push($errors, "login_error"); } $stmt->close(); } ?>