I'm not exactly sure what you are looking for, but in order to use form variables in a query, you can just reference them in the statement.
$query = "SELECT * FROM database WHERE username = '$username' AND password = '$password'";
In this example, username and password are the variables passed from the form.