thanks marky2coats...i split the code but the form is still in the wrong position. since i have no php knowledge at all i guess i overlooked something. this is the current code on the above mentioned link, maybe you can help re-shuffle the code???
<?php
// Variables
// Path to the config file.
$config = "conf.php";
// End Variables
// Load config file.
require($config);
// Initial File checks to make sure the files exist before using them.
if(!file_exists($user_data)) {
echo "<h1 align=\"center\">$user_data_file_not_exist</h1>";
exit;
}
elseif(!is_readable($user_data)) {
echo "<h1 align=\"center\">$user_data_file_not_readable</h1>";
exit;
}
elseif($log_login) {
if(!file_exists($log_file)) {
echo "<h1 align=\"center\">$log_file_not_exist</h1>";
exit;
}
elseif(!is_writable($log_file)) {
echo "<h1 align=\"center\">$log_file_not_writable</h1>";
exit;
}
}
// Perform operation according to command:
switch ($cmd) {
case "login":
if(check_user($username, $password, $name, $log_login)) {
session_start("pageprotect");
session_register('valid');
session_register('username');
session_register('name');
// Uses MD5 and soundex to encode "valid" var to avoid easy access.
$valid = strrev(soundex(name).md5($username));
if ($log_login) {
$fd = @fopen($log_file, "a");
fputs($fd, time()."|$name|$username\n");
fclose($fd);
}
header("Location: $first_page?".SID);
exit;
} else {
header("location: $login_page?cmd=invalid");
exit;
}
break;
case "unauth":
session_start("pageprotect");
session_destroy();
print_header();
echo "<h3 align=\"center\">$unauthorised</i></h3>";
print_login();
print_footer();
break;
case "invalid":
print_header();
echo "<h3 align=\"center\">$invalid_username_password</i></h3>";
print_login($username);
print_footer();
break;
case "logout":
session_start("pageprotect");
session_destroy();
print_header();
echo "<h3 align=\"center\">$logged_out</i></h3>";
print_login($username);
print_footer();
break;
default:
print_header();
print_login($username);
print_footer();
break;
}
function print_header() {
// Prints the header of the page.
echo "<html><head><title>Login</title></head><body style=\"font-family:verdana;\">";
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>esmertec : wireless software solutions for mass market mobile multimedia phones and embedded devices</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="description" content="Esmertec is the leading provider of wireless software solutions for mass market mobile multimedia phones and embedded devices">
<meta name="keywords" content="Java wireless mobile virtual machine Sun handset Smart phone Jbed Jeco cellular phone">
<meta name="author" content="Rana Doustdar">
<meta name="robots" content="index,follow">
<meta name="revisit-after" content="20 days">
<meta name="Content-Language" Content="en">
<link rel="stylesheet" href="/main.css" type="text/css">
</head>
<body bgcolor="#0066cc" text="#000000" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="70" bgcolor="#6699FF"> </td>
<td bgcolor="#6699FF"> </td>
<td bgcolor="#6699FF"> </td>
<td bgcolor="#6699FF"> </td>
</tr>
<tr>
<td height="46" bgcolor="#6699FF"> </td>
<td width="208" bgcolor="#6699FF"><a href="http://www.esmertec.com"><img src="/img/logo.gif" alt="Esmertec.com" width="208" height="46" border="0"></a></td>
<td bgcolor="#6699FF"> </td>
<td bgcolor="#6699FF"> </td>
</tr>
<tr>
<td bgcolor="#6699FF" height="12"> </td>
<td bgcolor="#6699FF"> </td>
<td valign="bottom" width="781" bgcolor="#6699FF"><img src="/nav/1.gif" width="781" height="12"></td>
<td bgcolor="#6699FF"> </td>
</tr>
<tr>
<td height="24" bgcolor="#FFFFFF"> </td>
<td bgcolor="#FFFFFF"> </td>
<td height="24" bgcolor="#FFFFFF">
<?php virtual ("/nav/nav.php");?>
</td>
<td bgcolor="#FFFFFF"> </td>
</tr>
<tr>
<td height="10" bgcolor="#FFFFFF"> </td>
<td bgcolor="#FFFFFF"> </td>
<td bgcolor="#FFFFFF"><table height="20" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="470"> </td>
<td width="100"> </td>
<td width="120" valign="bottom"><img src="/img/arrow.gif" width="12" height="17"><a class="menu" href="http://www.esmertec.com/investor_relations/secure/login.php">Login</a></td>
</tr>
</table></td>
<td bgcolor="#FFFFFF"> </td>
</tr>
<tr>
<td height="10" bgcolor="#FFFFFF"> </td>
<td rowspan="2" bgcolor="#FFFFFF"> </td>
<td bgcolor="#FFFFFF"> </td>
<td bgcolor="#FFFFFF"> </td>
</tr>
<tr>
<td height="300" bgcolor="#FFFFFF"> </td>
<td bgcolor="#FFFFFF"><p> </p>
<table width="600" border="0" cellspacing="0" cellpadding="0">
<tr>
<td valign="top">
<?php
function check_user($username, $password, &$name, &$log) {
// Checks to see the user is valid.
if(($username == $GLOBALS[admin_username]) && ($password == $GLOBALS[admin_password])) {
$name = "Administrator";
$log = false;
return true;
}
else {
$file = @file($GLOBALS[user_data]);
$pw = md5($password);
$valid = false;
if(is_array($file)) {
foreach($file as $user) {
$dat = explode("|", $user);
if($username==$dat[0] && $pw == trim($dat[2])) {
$valid = true;
$name = $dat[1];
}
}
}
return $valid;
}
}
function print_login($username='') {
// Prints the login form.
echo "<h2 align=\"center\"><i>$GLOBALS[user_login]</i></h2>
<form method=\"post\" action=\"$GLOBALS[SCRIPT_NAME]\">
<input type=\"hidden\" name=\"cmd\" value=\"login\">
<table align=\"center\">
<tr><td>Username:</td><td><input type=\"text\" name=\"username\" value=\"$username\"></td></tr>
<tr><td>Password:</td><td><input type=\"password\" name=\"password\"></td></tr>
<tr><td colspan=\"2\" align=\"center\"><input type=\"submit\" value=\"Login\"></td></tr></table></form>";
}
function print_footer() {
// Prints the footer of the page.
echo "<div align=\"center\"><font size=\"-9\">This is a Secure Login Site</font></div></body></html>";
}
?>
</td>
</tr>
</table>
<p> </p> </td>
<td bgcolor="#FFFFFF"> </td>
</tr>
<tr>
<td height="10" bgcolor="#FFFFFF"> </td>
<td bgcolor="#FFFFFF"> </td>
<td bgcolor="#FFFFFF"> </td>
<td bgcolor="#FFFFFF"> </td>
</tr>
<tr>
<td height="5"> </td>
<td valign="bottom" colspan="2"> </td>
<td> </td>
</tr>
<tr>
<td height="10">
<div align="center"></div></td>
<td height="10"><div align="left"><span class="copyright">
<?php virtual ("/copyright.txt");?>
</span></div></td>
<td height="10"> </td>
<td height="10"> </td>
</tr>
<tr>
<td colspan="4"> </td>
</tr>
</table>
</body>
</html>