I have this code at the moment, i want to take off document.location = 'nextpage.php?x=' + x + '&y=' + y + '&room=<?= $room ?>'; so its all on 1 page what is the code to make into 1 code instead of having 2 files, thanks.

Code:
<script type="text/javascript">
function locationRefresh(e) {
    e = e || window.event;
    var x = e.clientX;
    var y = e.clientY;
    document.location = 'nextpage.php?x=' + x + '&y=' + y + '&room=<?= $room ?>';
}
</script>
nextpage.php:
Code:
<?php
include "global.php";

$query3 = mysql_query("SELECT * FROM onlineusers WHERE username = '$username'")
or die("Could not insert data because ".mysql_error());
$qry3 = mysql_fetch_array( $query3 );

$x 			= $_GET['x'];
$y 			= $_GET['y'];
$myFile = "store/cords/x/$username.txt";
$fh = fopen($myFile, 'w') or die("can't open file");
$stringData = fread($fh, filesize($myFile));
fwrite($fh, $x);
fclose($fh);

$myFile2 = "store/cords/y/$username.txt";
$fh2 = fopen($myFile2, 'w') or die("can't open file");
$stringData2 = fread($fh2, filesize($myFile2));
fwrite($fh2, $y);
fclose($fh2);

if ($qry3[setaway]=="y")
{
include "setaway.php";
}

header('Location: usersonlineframe.php?room=' . $room);
?>