<html>
<header>
<?php
	include("/var/db.php");
?>
</header>
<body>

<?php

if ($_SERVER["REQUEST_METHOD"] == "GET") {
	try {
		$dbconn = getConnection($username, $login);
		$row = getRow($dbconn, $_GET["name"]); ?>
		//<?= "user: " . $username ?>
		<strong> The resulting row is: <strong> <br/>
		<?php
		print_r($row); 
	} catch (PDOEXception $ex) {
		header("HTTP/1.1 400 Invalid Request");
		print "big problem";
	}
}


?>
</body>
</html>

<?php

function getConnection($username, $login) {
	return new PDO("mysql:dbname=nerdluv;host=localhost", $username, $login,
		array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION));
}

function getRow($dbconn,$name) {
	$statement = $dbconn->prepare("SELECT * FROM users WHERE name = :name");
	$statement->execute(array(":name" => $name));
	return $statement->fetch(PDO::FETCH_ASSOC);
}
?>
