he meta tag isn't an option because that refreshes after X seconds. The code is below.
The only things in the include files are database connectivity and error messages.
The codeincludes my nasty workaround of calling the page again once the error variable has been set.
Basically the page displays and at the bottom of the screen table is an error message which the default is a space
(try it http:/193.122.28.177/ - doesn't seem to work under netscape at the mo). When submit is clicked, the database is checked and if an error is returned a session variable is set and the screen refreshes. Upon refresh it calls the session and set another variable which displays the error message. But as I said although it gets set I have to press refresh on my browser.
My workaround fixes the problem (but gives another display problem!) however it's not a 'neat' solution. Or at least I don't think it is.
Nick.
//----- CODE -----//
<?
// start the session
php_track_vars;
session_start();
if (!$PHPSESSID) {
session_register("user");
session_register("time_in");
session_register("error");
}else {
$error_code = $error;
}
?>
<head>
<title>[Dynamic Web Support] User Login</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<!--
////////////////////////////////////////////////////////////////////////
// //
// Copyright - Dynamic Web Solutions //
// - 19 Reading Road, Pangbourne, Berkshire, RG8 7LT, UK //
// //
// Project - DWS - Support //
// //
// Title - Login Page //
// File - login.php //
// Version - 0.2 //
// Date - 30.10.2000 //
// By - Nick Gushlow //
// //
// Target - Apache 1.3.12 with Mysql 3.22.22 and PHP 4.02 running //
// on Redhat 7.0 //
// //
// Purpose - Provide user authentication for the site //
// //
////////////////////////////////////////////////////////////////////////
-->
<link rel="stylesheet" type="text/css" href="css/main.css">
<script language="JavaScript">
<!--
function MM_preloadImages() { //v3.0
var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
if (a.indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a;}}
}
function MM_swapImgRestore() { //v3.0
var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a)&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_findObj(n, d) { //v3.0
var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers.document); return x;
}
function MM_swapImage() { //v3.0
var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
if ((x=MM_findObj(a))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function MM_reloadPage(init) { //reloads the window if Nav4 resized
if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);
function setFocus() { //set the focus to username input
document.login.username.focus();
}
// -->
</script>
</head>
<body bgcolor="#FFFFFF" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" onLoad="setFocus();MM_preloadImages('im/splash_signup_over.gif','im/splash_forgotpwd_over.gif')">
<?
// include database connectivity file
include ($DOCUMENT_ROOT.'/core/database.php');
include ($DOCUMENT_ROOT.'/core/error.php');
// connect to database
db_connect();
db_select();
// set variables
$verify_user = mysql_query("SELECT FROM user WHERE username = '$username'");
// secret hash variable
$dws_var = 'citrus';
// create the hash
$hash = md5($passwd.$dws_var);
$verify_hash = mysql_query("SELECT FROM user WHERE username = '$username' AND hash = '$hash'");
$access = mysql_query("SELECT access FROM user WHERE username = '$username' AND hash = '$hash'");
// ------- MAIN PROCEDURE ------- //
if ($submit_x) {
// process form
// Check to see if the user exists in the database
if (mysql_num_rows($verify_user) > 0) {
// check to see if the password is correct
if (mysql_num_rows($verify_hash) > 0) {
// check the access level of the user
if (mysql_result($access,0,access) == 1) {
// add session variables.
$user = $username;
$time_in = time();
/
mysql_query("INSERT INTO sessions (username,time_in)
/
echo "<script language=\"JavaScript\"> ";
echo "location='debug.php';";
echo "</script>";
}else if (mysql_result($access,0,access) == 1) {
$user = $username;
$time_in = time();
/
mysql_query("INSERT INTO sessions (username,time_in)
/
echo "<script language=\"JavaScript\"> ";
echo "location='debug.php';";
echo "</script>";
}else {
// strange error?! Much Wierdness!!
$error = 1000000;
echo "<script language=\"JavaScript\"> ";
echo "location='index.php';";
echo "</script>";
}
} else {
// error result = wrong password
$error = 2;
echo "<script language=\"JavaScript\"> ";
echo "location='index.php';";
echo "</script>";
}
} else {
// error result = user does not exist
$error = 1;
echo "<script language=\"JavaScript\"> ";
echo "location='index.php';";
echo "</script>";
}
}
?>
<form method="post" action="<?php echo $PHP_SELF?>" name="login">
<table width="100%" border="0" cellspacing="0" cellpadding="0" vspace="0" hspace="0" height="100%">
<tr>
<td height="50%"> </td>
</tr>
<tr align="center">
<td height="95">
<table width="400" border="0" cellspacing="0" cellpadding="0" height="94" vspace="0" hspace="0" align="center">
<tr>
<td width="301" height="45" valign="bottom" background="im/splash_tspacer.gif"><img src="im/splash_top.gif" width="301" height="45" border="0" vspace="0" hspace="0"></td>
<td rowspan="3" width="99">
<table width="99" border="0" cellspacing="0" cellpadding="0" height="94">
<tr>
<td><a href="signup.html" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('signup','','im/splash_signup_over.gif',1)"><img src="im/splash_signup.gif" width="99" height="15" border="0" vspace="0" hspace="0" alt="signup for support" name="signup"></a></td>
</tr>
<tr>
<td><img src="im/splash_right.gif" width="99" height="79" border="0" vspace="0" hspace="0"></td>
</tr>
</table>
</td>
</tr>
<tr>
<td height="25" background="im/splash_mspacer.gif">
<table width="301" border="0" cellspacing="0" cellpadding="0" height="25">
<tr>
<td width="4"></td><td><FONT size="1" face="Arial, Helvetica, sans-serif" color="#000000">Uid:</font></td>
<td valign="middle">
<FONT size=-1 point-size="7">
<input type="text" name="username" size="11" class="formInputLogin">
</font>
</td>
<td><FONT size="1" face="Arial, Helvetica, sans-serif" color="#000000">Pwd:</font></td>
<td valign="middle">
<FONT size=-1 point-size="7">
<input type="password" name="passwd" size="11" class="formInputLogin">
</font>
</td>
<td valign="middle" width="49">
<input type="image" border="0" name="submit" src="im/splash_login.gif" alt="login" width="49" height="10">
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td width="301" height="24" valign="bottom" background="im/splash_bspacer.gif" align="right"><a href="forgotpass.html" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('forgotpwd','','im/splash_forgotpwd_over.gif',1)"><img name="forgotpwd" border="0" src="im/splash_forgotpwd.gif" width="194" height="18"></a></td>
</tr>
<!--if error message != null then-->
<tr>
<td background="im/pixel_grey.gif" colspan="2"><FONT face="Arial, Helvetica, sans-serif" size="1" color="#cc0000"> <?php error_handling($error_code); ?></font></td>
</tr>
<!--end if-->
</table>
</td>
</tr>
<tr>
<td height="50%"> </td>
</tr>
</table>
</form>
</body>