<?php
    $GLOBALS['highlight'] = 'home';

    if ($GLOBALS['auth']['id'])
    {
        header('Location: ./');    
        die;
    }
    
    $_cache = isset($_GET['c']) ? trim(strval($_GET['c'])) : '';
    
    if ($_cache)
    {
        $cache = mysqli_query_logged("SELECT email FROM members_create WHERE cache = " . sq($_cache));
        if (!$cache = mysqli_fetch_assoc($cache))
        {
            make_cookie('notice', 'Sorry, there was a problem with that link, please try again.');
            header('Location: ./?s=new');
            die;
        }
    }
    else
    {
        make_cookie('notice', 'Sorry, there was a problem with that link, please try again.');
        header('Location: ./?s=new');
        die;
    }

    include('include/parts/header.php');
?>

<div class="header">Create An Account</div>
<?php
    if ($_notice)
    {
        echo '<div class="content">';
        echo '<span class="notice_error">' . $_notice . '</span>';
        echo '</div>';
    }
?>
<div class="content">
<form action="?a=new_complete" method="post" style="margin: 0px; display: inline;">
<input type="hidden" name="cache" value="<?php echo $_cache; ?>">
<table width="100%" border="0">
<?php
    echo '<tr><td width="150" style="text-align: right;">Username:</td><td><input name="name" size="40" style="border: solid 2px black; margin: 0px; padding: 3px;"></td></tr>';
    echo '<tr><td width="150" style="text-align: right;">Password:</td><td><input name="pass1" size="40" style="border: solid 2px black; margin: 0px; padding: 3px;"></td></tr>';
    echo '<tr><td width="150" style="text-align: right;">Retype Password:</td><td><input name="pass2" size="40" style="border: solid 2px black; margin: 0px; padding: 3px;"></td></tr>';
    echo '<tr><td width="150" style="text-align: right;"></td><td><input type="submit" value="Create Account" style="border: solid 1px green; background: black; color: green;"></td></tr>';
?>
</table>
</form>
</div>

<?php
    include('include/parts/footer.php');
?>