well rather then using javascript you can access what you need via PHP's $_POST function so if you had the elements name and password you could access them with:
$_POST['name'];
$_POST['password'];
so something like this for file2.php:
<?php
if(array_key_exists('submit', $_POST))
{
$username = $_POST['name'];
$password = $_POST['password'];
echo("Hello $username, your password is $password");
}
?>
That goes on the assumption of file1.php looking like:
<form action="file2.php" method="post">
Username:
<input type="text" name="name" />
<br />
Password:
<input type="password" name="password" />
<br />
<input type="submit" name="submit" />
</form>