How clean is my close_account code? Hello i'm coding a social site and I need to know how clean this code is. I read other answers people told me from my previous questions like this and used it as guidelines. So now I wanna know if anything could be improved. Thank you.
&lt;?php 

mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);
error_reporting(-1);

include 'includes/header.php';

$userLoggedIn = $_SESSION['thesocial_username'];

$post_id = isset($_POST['cancel']) ? header(&quot;Location: settings.php&quot;) : '';

if(isset($_POST['close_account'])) {
    
    $close_query = $con-&gt;prepare('UPDATE users SET user_closed = &quot;yes&quot; WHERE username = ?');
    $close_query-&gt;bind_param(&quot;s&quot;, $userLoggedIn);
    $close_query-&gt;execute();

    session_destroy();
    header(&quot;Location: register.php&quot;);
}

?&gt;

&lt;center&gt;
&lt;div class=&quot;close_column close_account&quot;&gt;
    
    &lt;h4&gt;Close Account&lt;/h4&gt;
    Are you sure you want to close your account ?&lt;br&gt;&lt;br&gt;

    Closing your account will hide your profile and activity from users.&lt;br&gt;&lt;br&gt;
    You can reopen your account at anytime by logging in.&lt;br&gt;&lt;br&gt;

    &lt;form action=&quot;close_account.php&quot; method=&quot;POST&quot;&gt;
        
        &lt;input type=&quot;submit&quot; name=&quot;close_account&quot; id=&quot;close_account&quot; value=&quot;Yes, Close my account.&quot;&gt;
        &amp;nbsp;&amp;nbsp;
        &lt;input type=&quot;submit&quot; name=&quot;cancel&quot; id=&quot;update_details&quot; value=&quot;Nevermind.&quot;&gt;

    &lt;/form&gt;
&lt;/div&gt;
&lt;/center&gt;
The code is overall good basic PHP and above the average. However, I would like it more structured.
For example, why you are setting the error reporting manually in this file? Apparently you have sort of a bootstrap file as includes/header.php, why not to put these lines there?
Besides, i don't see any point in the line assigning $post_id variable. What does a post id to do with deleting an account? And yes, such a syntax structure looks embarrassing.
It is also a good rule of thumb to follow Location header with an explicit exit call. Although it is not critical in this particular case, sometimes the lack of the script termination could pose a serious threat, as the header itself doesn't stop the script execution.
Some notes on the database structure

The computer world has its own representation for &quot;yes&quot; and &quot;no&quot;, it's 1 and 0 respectively. So consider making the field of tinyint type instead of varchar.
it is considered a good practice to address all database entities by the unique id. It's better to store the user id in the session and use it for all the database operations.

The code structure
One big issue I overlooked at first is the structure of your script. It seems that includes/header.php is not just a bootstrap file but it also starts some HTML output. that's a big NO. An HTTP header such as Location cannot be sent after HTML. Your PHP lets you to do it due to some permissive setting, but it is nevertheless wrong, from the logical and technological points of view. It just makes no sense to start any output when your script is not going to display anything but would only redirect to another page.
Split your includes/header.php file into two: bootstrap.php and header.php. The former should contain all the configuration options such as database connection, error reporting etc, but not a byte should it output. And the latter would contain all the HTML.
Than make your code like this
&lt;?php 

include 'includes/bootstrap.php';

$id= $_SESSION['user_id'];

if(isset($_POST['close_account']))
{
    $stmt = $con-&gt;prepare('UPDATE users SET user_closed = 1 WHERE id = ?');
    $stmt-&gt;bind_param(&quot;s&quot;, $id);
    $stmt-&gt;execute();

    session_destroy();
    header(&quot;Location: register.php&quot;);
    exit;
}
include 'includes/header.php';
?&gt;
&lt;center&gt;