php网页密码空验证

I wanted to check if the username and password fields are empty. If they are empty it should give a error message box and the message box should contain a message and a ok button. When user clicks the ok button the msg box should close and user should see the login page.

For that i wrote the below code. but after pressing the ok button on error message box the web page address is remaining same but the content is not getting displayed , full white page is displayed.

you do refresh and page comes back.

This is the file i am opening in browser register.php

<?php

// configuration
require("../includes/config.php");

// if user reached page via GET (as by clicking a link or via redirect)
if ($_SERVER["REQUEST_METHOD"] == "GET")
{
    // else render form
    render("register_form.php", ["title" => "Register"]);
}

// else if user reached page via POST (as by submitting a form via POST)
else if ($_SERVER["REQUEST_METHOD"] == "POST")
{
    // TODO
    if (empty($_POST["username"]) || empty($_POST["password"]))
    {
        $message = "Username and/or Password empty.\
Try again.";
        echo "<script type='text/javascript'>alert('$message');</script>";
    }   
}
?>

And this is the form file register_form.php

<form action="register.php" method="post">
<fieldset>
    <div class="form-group">
        <label>Username :</label>
        <input autofocus class="form-control" name="username" placeholder="Username" type="text"/>
    </div>
    <div class="form-group">
         <label>Password :</label>
        <input class="form-control" name="password" placeholder="Password" type="password"/>
    </div>
    <div class="form-group">
         <label>Password :</label>
        <input class="form-control" name="confirmation" placeholder="Retype-Password" type="password"/>
    </div>
    <div class="form-group">
        <button type="submit" class="btn btn-default">Register</button>
    </div>
</fieldset>
</form>

i want to see login page after clicking the ok button on the message box i do not want to see white page. please help