In my php script, I have a simple username/ email exists condition, but I want to put the error (should it exist) somewhere in my html, so that I can style it and position it over my form. Echo just puts it top-left. How can I do that? Setting a variable seems like not the optimal solution.
<?php
require('connect.php');
if(isset($_POST["register"])){
    $username = $_POST["username"];
    $password = $_POST["password"];
    $email = $_POST["email"];
    $username = mysqli_real_escape_string($conn, $username);
    $password = mysqli_real_escape_string($conn, $password);
    $email = mysqli_real_escape_string($conn, $email);
    $conflictUserQuery = "SELECT username FROM members WHERE username='$username'";
    $conflictUserResult = mysqli_query($conn, $conflictUserQuery);
    $conflictUserRow = mysqli_fetch_array($conflictUserResult, MYSQLI_ASSOC);
    $conflictMailQuery = "SELECT email FROM members WHERE email='$email'";
    $conflictMailResult = mysqli_query($conn, $conflictMailQuery);
    $conflictMailRow = mysqli_fetch_array($conflictMailResult, MYSQLI_ASSOC);
    if(mysqli_num_rows($conflictMailResult) ==1){
        echo "Could not be registered. Mail exists.";
    }
    elseif(mysqli_num_rows($conflictUserResult) ==1){
        echo "Could not be registered. Username exists.";
    }
    else{
        $registerQuery = mysqli_query($conn, "INSERT INTO members (username, password, email) VALUES ('$username', '$password', '$email')");
        if($registerQuery){
            echo "Thank You! you are now registered.";
        }
    }
}
?>
<!DOCTYPE html>
<html>
    <head>
        <link rel="stylesheet" href="css/style.css">
        <link href="https://fonts.googleapis.com/css?family=Montserrat" rel="stylesheet">
        <title>Blog</title>
    </head>
    <body>
        <div class="flex-enable flex-center">
            <div class="flex-enable flex-center semiOverride flex-center px100">
                <div class="flex-enable flex-center flex-column">
                    <h2 class="big-white-title">Register.</h2>
                    <h3 class="medium-white-title">Be a part of this.</h3>
                <form class="flex-enable flex-center flex-column" method="POST">
                    <input class="form-input-text small-white-title" type="text" name="username" placeholder="Username">
                    <input class="form-input-text small-white-title" type="text" name="password" placeholder="Password">
                    <input class="form-input-text small-white-title" type="text" name="email" placeholder="e-mail">
                    <input class="form-button small-white-title" type="submit" name="register" value="Register">
                </form>
                <h3 class="small-white-subtitle">Or <a id="register" href="">login</a> if you have an account.</h3>
                </div>
            </div>
        </div>
        <div id="attribution">Photo by <a href="https://unsplash.com/@meindrittesauge">Sebastian Kanczok</a></div>
    </body>
</html>
 
    