<?php
error_reporting(E_ALL^E_NOTICE);
?>
<html>
	<head></head>
	<style type="text/css">
*
{
	margin: 0;
	padding: 0;
	border: 0;
}

body
{
	font-family: Arial;
	font-size: 25px;
	background-color: #CCC;
	text-align: center;
}

table
{
	margin: 20px 0 0 0;
	width: 100%;
}

td.right
{
	text-align: right;
}

#p
{
	margin: auto;
	padding: 5px 10px;
	border-radius: 15px;
	-moz-border-radius: 15px;
	-webkit-border-radius: 15px;
	border: #A70 1px solid;
	text-shadow: #FFF -1px -1px 2px, #FFF 0 0 4px, #FFF 1px 1px 2px;
	-moz-text-shadow: #FFF -1px -1px 2px, #FFF 0 0 4px, #FFF 1px 1px 2px;
	-webkit-text-shadow: #FFF -1px -1px 2px, #FFF 0 0 4px, #FFF 1px 1px 2px;
	background-color: #777;
	display: table;
}

#n
{
	margin: 10px 0 0 0;
}

#b
{
	margin: 30px auto 0 auto;
	padding: 3px 50px;
	border-radius: 6px;
	-moz-border-radius: 6px;
	-webkit-border-radius: 6px;
	border: #035 1px solid;
	color: #FFF;
	text-shadow: #000 0 0 4px;
	-moz-text-shadow: #000 0 0 4px;
	-webkit-text-shadow: #000 0 0 4px;
	background: #7BF;
	background: -moz-linear-gradient(top, #7CF, #257);
	background: -webkit-gradient(linear, left top, left bottom, from(#7CF), to(#257));
	font-size: 80%;
	display: table;
}

input[type=text]
{
	font-size: 25px;
}
	</style>
	<script type="text/javascript">
//------------------------------------------------------------------------------
function o(	// objeto
	i	// identidad: string
	)	// : object
{
	return document.getElementById(i);
}
	</script>
	<body>
<?php
if (strlen($_REQUEST['n']) && strlen($_REQUEST['p'])):
	$b = mysql_connect('XXX', 'XXX', 'XXX');	// data base
	if (!$b)
		die('Could not connect to MySQL: '.mysql_error());

	if (!mysql_select_db('XXX'))
		die('Could not select data base: '.mysql_error());

	$r = mysql_query("INSERT INTO jewels (name, score) VALUES ('".$_REQUEST['n']."', '".$_REQUEST['p']."')");	// result
	if (!$r)
		die('Invalid query: '.mysql_error());
?>
		<div>Thank you for submitting your score!</div>
		<div style="margin-top:20px;font-size:40%">(Close this window to continue)</div>
<?php
else:
?>
		<div id="p">Your Score:&nbsp;<?php echo $_REQUEST['p'] ?></div>
		<form id="f">
			<input type="hidden" name="p" value="<?php echo $_REQUEST['p'] ?>">
			<div id="n">Your Name:&nbsp;<input type="text" name="n"/></div>
		</form>
		<div id="b" onClick="o('f').submit()">Submit Score</div>
<?php
endif;
?>
	</body>
</html>