<?php
// Connect to database server. Replace info with the info you have. (SERVER will most likely be "localhost");
$conn = mysql_connect(SERVER, USERNAME, PASSWORD) or die("Unable to connect to database server. ".mysql_error());
// Select database. Replace DATABASE with the name of your database.
mysql_select_db(DATABASE, $conn) or die("Failed to select database.");
// Write the SQL-query to fetch the data
// $_GET[] is an array that contains the data sent via the form. If you use "POST" as method you just use $_POST[] instead.
// So if you have an input field with an id of "username" you would use $_GET["username"] to retrieve that value.
$sql = "SELECT some_id FROM some_table WHERE username = '".mysql_escape_string($_GET["username"])."' AND password = '".mysql_escape_string($_GET["password"])."'";
// Run the query
$res = mysql_query($sql) or die("Query failed:<br />".$sql."<br />".mysql_error());
// Put result in $row
$row = mysql_fetch_array($res);
// Redirect user to correct page.
header("Location:some_page.php?some_id=".$row["some_id"]);
?>