<commit_before><?php include 'header.php'; ?>

<?php function updateUser()
{

    include 'dbConnect.php';

    $title = $_POST["title"];
    $forename = $_POST["forename"];
    $surname = $_POST["surname"];
    $street = $_POST["street"];
    $county = $_POST["county"];
    $city = $_POST["city"];
    $post_code = $_POST["post_code"];
    $contact_phone_region = $_POST["contact_phone_region"];
    $contact_phone = $_POST["contact_phone"];
    $contact_email = $_POST["contact_email"];


    if (!empty($title)) {
        //$query = "UPDATE `customer` SET title = '$title' WHERE username = '$_SESSION[username]'";
        //$result = mysqli_query($db, $query) or die(mysqli_error($db));
		$query = mysqli_prepare($db,"UPDATE `customer` SET title = ? WHERE username = ?");
		mysqli_stmt_bind_param($query,'ss',$title,$username);
		mysqli_stmt_execute($query);
		mysqli_stmt_close($query);
		
    }

    if (!empty($forename)) {
        /*$query = "UPDATE `customer` SET forename = '$forename' WHERE username = '$_SESSION[username]'";
        $result = mysqli_query($db, $query) or die(mysqli_error($db));*/
		$query = mysqli_prepare($db,"UPDATE `customer` SET forename = ? WHERE username = ?");
		mysqli_stmt_bind_param($query,'ss',$forename,$username);
		mysqli_stmt_execute($query);
		mysqli_stmt_close($query);
    }

    if (!empty($surname)) {
        /*$query = "UPDATE `customer` SET surname = '$surname' WHERE username = '$_SESSION[username]'";
        $result = mysqli_query($db, $query) or die(mysqli_error($db));*/
		$query = mysqli_prepare($db,"UPDATE `customer` SET surname = ? WHERE username = ?");
		mysqli_stmt_bind_param($query,'ss',$surname,$username);
		mysqli_stmt_execute($query);
		mysqli_stmt_close($query);
    }

    if (!empty($street)) {
        /*$query = "UPDATE `customer` SET street = '$street' WHERE username = '$_SESSION[username]'";
        $result = mysqli_query($db, $query) or die(mysqli_error($db));*/
		$query = mysqli_prepare($db,"UPDATE `customer` SET street = ? WHERE username = ?");
		mysqli_stmt_bind_param($query,'ss',$street,$username);
		mysqli_stmt_execute($query);
		mysqli_stmt_close($query); 
		
    }

    if (!empty($county)) {
        /*$query = "UPDATE `customer` SET county = '$county' WHERE username = '$_SESSION[username]'";
        $result = mysqli_query($db, $query) or die(mysqli_error($db));*/
		$query = mysqli_prepare($db,"UPDATE `customer` SET county = ? WHERE username = ?");
		mysqli_stmt_bind_param($query,'ss',$county,$username);
		mysqli_stmt_execute($query);
		mysqli_stmt_close($query); 
		
    }

    if (!empty($city)) {
        /*$query = "UPDATE `customer` SET city = '$city' WHERE username = '$_SESSION[username]'";
        $result = mysqli_query($db, $query) or die(mysqli_error($db));*/
		$query = mysqli_prepare($db,"UPDATE `customer` SET city = ? WHERE username = ?");
		mysqli_stmt_bind_param($query,'ss',$city,$username);
		mysqli_stmt_execute($query);
		mysqli_stmt_close($query); 
    }

    if (!empty($post_code)) {
        /*$query = "UPDATE `customer` SET post_code = '$post_code' WHERE username = '$_SESSION[username]'";
        $result = mysqli_query($db, $query) or die(mysqli_error($db));*/
		$query = mysqli_prepare($db,"UPDATE `customer` SET post_code = ? WHERE username = ?");
		mysqli_stmt_bind_param($query,'ss',$post_code,$username);
		mysqli_stmt_execute($query);
		mysqli_stmt_close($query); 
    }

    if (!empty($contact_phone_region)) {
        /*$query = "UPDATE `customer` SET contact_phone_region = '$contact_phone_region' WHERE username = '$_SESSION[username]'";
        $result = mysqli_query($db, $query) or die(mysqli_error($db));*/
		$query = mysqli_prepare($db,"UPDATE `customer` SET contact_phone_region = ? WHERE username = ?");
		mysqli_stmt_bind_param($query,'ss',$contact_phone_region,$username);
		mysqli_stmt_execute($query);
		mysqli_stmt_close($query); 
    }

    if (!empty($contact_phone)) {
        /*$query = "UPDATE `customer` SET contact_phone = '$contact_phone' WHERE username = '$_SESSION[username]'";
        $result = mysqli_query($db, $query) or die(mysqli_error($db));*/
		$query = mysqli_prepare($db,"UPDATE `customer` SET contact_phone = ? WHERE username = ?");
		mysqli_stmt_bind_param($query,'ss',$contact_phone,$username);
		mysqli_stmt_execute($query);
		mysqli_stmt_close($query); 
    }

    if (!empty($contact_email)) {
        /*$query = "UPDATE `customer` SET contact_email = '$contact_email' WHERE username = '$_SESSION[username]'";
        $result = mysqli_query($db, $query) or die(mysqli_error($db));*/
		$query = mysqli_prepare($db,"UPDATE `customer` SET contact_email = ? WHERE username = ?");
		mysqli_stmt_bind_param($query,'ss',$contact_email,$username);
		mysqli_stmt_execute($query);
		mysqli_stmt_close($query); 
		
    }
}

if (isset($_POST["UpdateAccount"])) {
    updateUser();

    echo
    '<div class="container">
            <div class="row">
                <div class="col-md-12">
                    <h2 style="text-align:center">Thanks for updating your details!</h2>
                </div>
            </div>
        </div>';
} ?>

<?php include 'footer.php'; ?><commit_msg>craig recent changes - username sorted<commit_after><?php include 'header.php'; ?>

<?php function updateUser()
{

    include 'dbConnect.php';

    $title = $_POST["title"];
    $forename = $_POST["forename"];
    $surname = $_POST["surname"];
    $street = $_POST["street"];
    $county = $_POST["county"];
    $city = $_POST["city"];
    $post_code = $_POST["post_code"];
    $contact_phone_region = $_POST["contact_phone_region"];
    $contact_phone = $_POST["contact_phone"];
    $contact_email = $_POST["contact_email"];


    if (!empty($title)) {
        //$query = "UPDATE `customer` SET title = '$title' WHERE username = '$_SESSION[username]'";
        //$result = mysqli_query($db, $query) or die(mysqli_error($db));
		$query = mysqli_prepare($db,"UPDATE `customer` SET title = ? WHERE username = ?");
		mysqli_stmt_bind_param($query,'ss',$title,$_SESSION['username']);
		mysqli_stmt_execute($query);
		mysqli_stmt_close($query);
		
    }

    if (!empty($forename)) {
        /*$query = "UPDATE `customer` SET forename = '$forename' WHERE username = '$_SESSION[username]'";
        $result = mysqli_query($db, $query) or die(mysqli_error($db));*/
		$query = mysqli_prepare($db,"UPDATE `customer` SET forename = ? WHERE username = ?");
		mysqli_stmt_bind_param($query,'ss',$forename,$_SESSION['username']);
		mysqli_stmt_execute($query);
		mysqli_stmt_close($query);
    }

    if (!empty($surname)) {
        /*$query = "UPDATE `customer` SET surname = '$surname' WHERE username = '$_SESSION[username]'";
        $result = mysqli_query($db, $query) or die(mysqli_error($db));*/
		$query = mysqli_prepare($db,"UPDATE `customer` SET surname = ? WHERE username = ?");
		mysqli_stmt_bind_param($query,'ss',$surname,$_SESSION['username']);
		mysqli_stmt_execute($query);
		mysqli_stmt_close($query);
    }

    if (!empty($street)) {
        /*$query = "UPDATE `customer` SET street = '$street' WHERE username = '$_SESSION[username]'";
        $result = mysqli_query($db, $query) or die(mysqli_error($db));*/
		$query = mysqli_prepare($db,"UPDATE `customer` SET street = ? WHERE username = ?");
		mysqli_stmt_bind_param($query,'ss',$street,$_SESSION['username']);
		mysqli_stmt_execute($query);
		mysqli_stmt_close($query); 
		
    }

    if (!empty($county)) {
        /*$query = "UPDATE `customer` SET county = '$county' WHERE username = '$_SESSION[username]'";
        $result = mysqli_query($db, $query) or die(mysqli_error($db));*/
		$query = mysqli_prepare($db,"UPDATE `customer` SET county = ? WHERE username = ?");
		mysqli_stmt_bind_param($query,'ss',$county,$_SESSION['username']);
		mysqli_stmt_execute($query);
		mysqli_stmt_close($query); 
		
    }

    if (!empty($city)) {
        /*$query = "UPDATE `customer` SET city = '$city' WHERE username = '$_SESSION[username]'";
        $result = mysqli_query($db, $query) or die(mysqli_error($db));*/
		$query = mysqli_prepare($db,"UPDATE `customer` SET city = ? WHERE username = ?");
		mysqli_stmt_bind_param($query,'ss',$city,$_SESSION['username']);
		mysqli_stmt_execute($query);
		mysqli_stmt_close($query); 
    }

    if (!empty($post_code)) {
        /*$query = "UPDATE `customer` SET post_code = '$post_code' WHERE username = '$_SESSION[username]'";
        $result = mysqli_query($db, $query) or die(mysqli_error($db));*/
		$query = mysqli_prepare($db,"UPDATE `customer` SET post_code = ? WHERE username = ?");
		mysqli_stmt_bind_param($query,'ss',$post_code,$_SESSION['username']);
		mysqli_stmt_execute($query);
		mysqli_stmt_close($query); 
    }

    if (!empty($contact_phone_region)) {
        /*$query = "UPDATE `customer` SET contact_phone_region = '$contact_phone_region' WHERE username = '$_SESSION[username]'";
        $result = mysqli_query($db, $query) or die(mysqli_error($db));*/
		$query = mysqli_prepare($db,"UPDATE `customer` SET contact_phone_region = ? WHERE username = ?");
		mysqli_stmt_bind_param($query,'ss',$contact_phone_region,$_SESSION['username']);
		mysqli_stmt_execute($query);
		mysqli_stmt_close($query); 
    }

    if (!empty($contact_phone)) {
        /*$query = "UPDATE `customer` SET contact_phone = '$contact_phone' WHERE username = '$_SESSION[username]'";
        $result = mysqli_query($db, $query) or die(mysqli_error($db));*/
		$query = mysqli_prepare($db,"UPDATE `customer` SET contact_phone = ? WHERE username = ?");
		mysqli_stmt_bind_param($query,'ss',$contact_phone,$_SESSION['username']);
		mysqli_stmt_execute($query);
		mysqli_stmt_close($query); 
    }

    if (!empty($contact_email)) {
        /*$query = "UPDATE `customer` SET contact_email = '$contact_email' WHERE username = '$_SESSION[username]'";
        $result = mysqli_query($db, $query) or die(mysqli_error($db));*/
		$query = mysqli_prepare($db,"UPDATE `customer` SET contact_email = ? WHERE username = ?");
		mysqli_stmt_bind_param($query,'ss',$contact_email,$_SESSION['username']);
		mysqli_stmt_execute($query);
		mysqli_stmt_close($query); 
		
    }
}

if (isset($_POST["UpdateAccount"])) {
    updateUser();

    echo
    '<div class="container">
            <div class="row">
                <div class="col-md-12">
                    <h2 style="text-align:center">Thanks for updating your details!</h2>
                </div>
            </div>
        </div>';
} ?>

<?php include 'footer.php'; ?>
{'fraction_non_alphanumeric': 0.18107823422388203, 'fraction_numerical': 0.0007660633917456669, 'mean_word_length': 4.397416020671835, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3910904', 'n_tokens_mistral': 3646, 'n_tokens_neox': 3424, 'n_words': 624}