Hi
can some nice person tell me where I've gone wrong with this code. It puzzles me that it works but in my test environment throws up these two errors
Notice: Undefined index: username in G:\sites\edwards\login.php on line 7
Notice: Undefined index: password in G:\sites\edwards\login.php on line 8
The code is as below
thanks
Ian
<?php
session_start();
$user = $_REQUEST["username"];
$pass = $_REQUEST["password"];
if ($user == 'admin' && $pass =='starwood') {
$_SESSION['loggedin'] = TRUE;
header( 'Location: test.php' ) ;
} elseif ($user == 'millstream' && $pass =='nicola') {
$_SESSION['loggedin'] = TRUE;
header( 'Location: test.php' ) ;
} else {
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"<html xmlns="<head>
<SCRIPT LANGUAGE="JavaScript">
function placeFocus() {
if (document.forms.length > 0) {
var field = document.forms[0];
for (i = 0; i < field.length; i++) {
if ((field.elements.type == "text") || (field.elements.type ==
"textarea") || (field.elements.type.toString().charAt(0) == "s")) {
document.forms[0].elements.focus();
break;
}
}
}
}
</script>
<link href="emlogon.css" rel="stylesheet" type="text/css" />
</head>
<body OnLoad="placeFocus()">
<div id="header">
<div id="logo">
<div align="center"><img src="graphics/administration.jpg" alt="admin"
/></div>
</div>
</div>
<center>
<form method="post" action="login.php">
<p>User Name </p>
<p>
<input name="username" type="text">
</p>
<p>Password </p>
<p>
<input name="password" type="password">
</p>
<p>
<input name="Login" type="submit" value="Login">
</p>
</form>
</center>
</body>
</html>
<?php
}
?>
can some nice person tell me where I've gone wrong with this code. It puzzles me that it works but in my test environment throws up these two errors
Notice: Undefined index: username in G:\sites\edwards\login.php on line 7
Notice: Undefined index: password in G:\sites\edwards\login.php on line 8
The code is as below
thanks
Ian
<?php
session_start();
$user = $_REQUEST["username"];
$pass = $_REQUEST["password"];
if ($user == 'admin' && $pass =='starwood') {
$_SESSION['loggedin'] = TRUE;
header( 'Location: test.php' ) ;
} elseif ($user == 'millstream' && $pass =='nicola') {
$_SESSION['loggedin'] = TRUE;
header( 'Location: test.php' ) ;
} else {
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"<html xmlns="<head>
<SCRIPT LANGUAGE="JavaScript">
function placeFocus() {
if (document.forms.length > 0) {
var field = document.forms[0];
for (i = 0; i < field.length; i++) {
if ((field.elements.type == "text") || (field.elements.type ==
"textarea") || (field.elements.type.toString().charAt(0) == "s")) {
document.forms[0].elements.focus();
break;
}
}
}
}
</script>
<link href="emlogon.css" rel="stylesheet" type="text/css" />
</head>
<body OnLoad="placeFocus()">
<div id="header">
<div id="logo">
<div align="center"><img src="graphics/administration.jpg" alt="admin"
/></div>
</div>
</div>
<center>
<form method="post" action="login.php">
<p>User Name </p>
<p>
<input name="username" type="text">
</p>
<p>Password </p>
<p>
<input name="password" type="password">
</p>
<p>
<input name="Login" type="submit" value="Login">
</p>
</form>
</center>
</body>
</html>
<?php
}
?>