<?php
	$hostname = 'localhost';
	$username = 'narKampen';
	$pass = 'IfRLzj2HJBXA9eei';
	$database = 'narKampen';
	
	$conn = new mysqli($hostname, $username, $pass, $database);
	if (!$conn) {
		die("Connection Failed. ". mysqli_connect_error());
	}
	mysqli_set_charset($conn,'utf8');
	
	$newUsername = $conn->real_escape_string($_GET['name']);
	$newPassword = $conn->real_escape_string($_GET['password']);
	$newEmail = $conn->real_escape_string($_GET['email']);
	$salt = $conn->real_escape_string($_GET['s']);
	$deviceId = $conn->real_escape_string($_GET['did']);
	$os = $conn->real_escape_string($_GET['os']);
	
	if ($newUsername == '' || $newPassword == '' || $newEmail == '' || $salt == '') {
		echo "Supply values for all required fields";
		return;
	}
	
	$sql = "INSERT INTO users (username, password, email, salt, last_login, os, deviceId) VALUES ('$newUsername', '$newPassword', '$newEmail', '$salt', NOW(), '$os', '$deviceId')";
	if ($conn->query($sql) === true) {
		echo $conn->insert_id;
	} else {
		echo "Error while registering new user " . $conn->error;
	}
	$conn->close();
	
?>