<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>

<?php
// This is the PHP script

$dbconn pg_connect("host=cs.georgefox.edu dbname=natesladder user=ngeorgeson password=natepost00");

$query 'SELECT rank FROM Player WHERE rank is NOT NULL';

$countRank pg_query($query);

$newRank pg_num_rows($countRank) + 1;

//echo $newRank;

$name $_POST["name"];
$email $_POST["email"];
$phone $_POST["phone"];
$username $_POST["loginName"];
$password $_POST["loginPass"];

$password md5($password);
$password substr($password,0,8);



$required = array($name,$email,$username,$password);

$empty false;

foreach (
$required as $input)
{
    if (
$input == "")
    {
        
$empty true;
    }
}

if (
$empty == false)
{
    
    
pg_query("PREPARE add_player (text, text, int, text, text, text, boolean) AS INSERT INTO Player(name, email, rank, phone, username, password, active)
    VALUES($1, $2, $3, $4, $5, $6, $7)"
);
    
    
$insertTry pg_query("EXECUTE add_player('{$name}', '{$email}', $newRank, '{$phone}', '{$username}', '{$password}', true)");
    
    
pg_query("DEALLOCATE add_player");
    
    if (
$insertTry)
    {
        
session_start();
        
$_SESSION['currentUser'] = $username;
        
        
header("Location: userhub.php");
    }
    else
    {
        echo 
"Sign up Failure!";
    }
    
    
}

else
{
    echo 
"Sign up Failure!";
}
    
$_SESSION['defaultPanel'] = 0;
?>
</body>
</html>