~skye/poker/act/mkroom.php

view raw


<?php

require '../com.php';
require '../src/room.php';

try {
	form_has_post([
		"name" => [1, 32],
		"size" => [1, 64]
	]);
} catch (Exception $e) {
	exit(page_err(
		"invalid form parameters: " . $e->getMessage()
	));
}

$db = new Database("../run/poker.db");
$me = whoami($db);

if (!!$me) {
	$n = $_POST["name"];
	$s = (int)$_POST["size"];
	$r = new Room($n, $s, $me->id);
	$r->add_owner();

	header("Location: /act/join.php?h={$r->hash}");
} else {
	echo page_err("failed to login");
}

?>