I'm trying to incorporate my user login script into my html content below. Does anyone have any good ideas how I would start this.

my php script is below the html content

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>

<link href="index_layout.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="Layer1">
<div id="Layer2"><img src="untitled/waplogo4.gif" alt="wap_logo" width="434" height="129" /></div>
<div id="Layer3">
<div id="Layer4"><a href="register.php"><img src="untitled/Signup.gif" alt="sign_up" width="110" height="33" border="0" /></a></div>
<div id="Layer5"><img src="untitled/homebutton.gif" alt="homebutton" width="80" height="31" /></div>
<div id="Layer6"><a href="view_users.php"><img src="untitled/psbutton.gif" alt="party_search" width="157" height="33" border="0" /></a></div>
<div id="Layer7"><img src="untitled/HIWbutton.gif" alt="howitworks" width="160" height="28" /></div>
<div id="Layer8"><img src="untitled/FAQ's.gif" alt="faq" width="80" height="30" /></div>
<div id="Layer9"><a href="login.php"><img src="untitled/Sign-In.gif" alt="sign_in" width="95" height="33" border="0" /></a></div>
<div id="Layer10"><img src="untitled/About-Us.gif" alt="aboutus" width="113" height="31" /></div>
<div id="Layer11"><img src="untitled/Contact-Us.gif" alt="contact_us" width="139" height="37" /></div>
<img src="untitled/navbar.gif" alt="navbar" width="182" height="410" /></div>
<div id="Layer12"><img src="untitled/homepage_pic.gif" alt="friends_pic" width="250" height="166" /></div>
<div id="Layer13">
<div id="Layer16">
<form action="index.php" method="post" >
<table width="254" cellspacing="0">
<tr>
<td colspan="2"></td>
</tr>
<tr>
<td width="101">Email Address/td>
<td width="157"><label>
<input type="text" name="email" size="20" maxlength="40" />
</label></td>
</tr>
<tr>
<td>Password: </td>
<td><label>
<input type="password" name="password" size="20" maxlength="40" />
</label></td>
</tr>
<tr>
<td>&nbsp;</td>
<td><input type="submit" name="Submit" value="Login" />
<input type="hidden" name="submitted" value="TRUE" /></td>
</tr>
</table>
</form>
</div>
<img src="untitled/loginban.gif" alt="login_bar" width="280" height="157" /></div>
<div id="Layer14"><img src="untitled/missionstate.gif" alt="mission_statment" width="250" height="260" /></div>
<img src="untitled/background.gif" width="780" height="648" alt="bg_image" /></div>
</body>
</html>


////////////////////////////////////begining of php scipt//////////////////////////

<?php # Script 9.15 - login.php
// Send NOTHING to the Web browser prior to the session_start() line!

// Check if the form has been submitted.
if (isset($_POST['submitted'])) {

require_once ('./mysql_connect.php'); // Connect to the db.

$errors = array(); // Initialize error array.

// Check for an email address.
if (empty($_POST['email'])) {
$errors[] = 'You forgot to enter your email address.';
} else {
$e = escape_data($_POST['email']);
}

// Check for a password.
if (empty($_POST['password'])) {
$errors[] = 'You forgot to enter your password.';
} else {
$p = escape_data($_POST['password']);
}

if (empty($errors)) { // If everything's OK.

/* Retrieve the user_id and first_name for
that email/password combination. */
$query = "SELECT user_id, first_name FROM users WHERE email='$e' AND password=SHA('$p')";
$result = @mysql_query ($query); // Run the query.
$row = mysql_fetch_array ($result, MYSQL_NUM); // Return a record, if applicable.

if ($row) { // A record was pulled from the database.

// Set the session data & redirect.
session_name ('YourVisitID');

$_SESSION['user_id'] = $row[0];
$_SESSION['first_name'] = $row[1];
$_SESSION['agent'] = md5($_SERVER['HTTP_USER_AGENT']);

// Redirect the user to the loggedin.php page.
// Start defining the URL.
$url = 'http://' . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']);
// Check for a trailing slash.
if ((substr($url, -1) == '/') OR (substr($url, -1) == '\\') ) {
$url = substr ($url, 0, -1); // Chop off the slash.
}
// Add the page.
$url .= '/loggedin.php';

header("Location: $url");
exit(); // Quit the script.

} else { // No record matched the query.
$errors[] = 'The email address and password entered do not match those on file.'; // Public message.
$errors[] = mysql_error() . '<br /><br />Query: ' . $query; // Debugging message.
}

} // End of if (empty($errors)) IF.

mysql_close(); // Close the database connection.

} else { // Form has not been submitted.

$errors = NULL;

} // End of the main Submit conditional.

// Begin the page now.


if (!empty($errors)) { // Print any error messages.
echo '<h1 id="mainhead">Error!</h1>
<p class="error">The following error(s) occurredbr />';
foreach ($errors as $msg) { // Print each error.
echo " - $msg<br />\n";
}
echo '</p><p>Please try again.</p>';
}


?>