Simple Form Question<

admin

Administrator
Staff member
I'm not sure if this is a php or simple html question. I'm writing a login script but am sorta confused with the result. Here is the code snippet:


<html>
<head><title>A Sample Login Page</title></head>
<body>
<SCRIPT language="JavaScript" src=http://www.htmlforums.com/archive/index.php/"gulfOwnerTable.js"></SCRIPT>

<? function printLoginForm() {
print <<<HERE
<p>
<form action="login.php" name="loginForm"
method="post" onSubmit="return checkUserAndPass();">
<h2>You much login to view these pages</h2>
<table border="1">
<th colspan="2">LOGIN PAGE!</th>
<tr>
<td>Login:</td>
<td><input type="text" maxlength="10" size="12" name="username" size="7"></td></tr>
<tr>
<td>Password:</td>
<td><input type="password" maxlength="10" size="12" name="password" size="7"></td></tr>
<tr><td colspan="2" align="center"><input type="submit" value="Login!"></td></tr>
</form></p>
HERE;
}
?>

<?
$loginUserName = $_REQUEST["username"];
$loginPassWord = $_REQUEST["password"];
if((!isset($loginUserName))&&(!isset($loginPassWord))) {
printLoginForm();
print "past the function";
?>


I can't figure out why when I view the result in the browners, the last print statement:

print "past the function";

Always comes out on top of the table, even though it appears after the table in the html output. I know this is s simple problem but I'm stuck. I'd like to print the result of the login below the table, so that the structure of the page on top remains the same.because this "past the function" is not in the table and the browser will always stick it at the top. you need tou stick it in a cell in order to have it on the table.

the function closes the row with a </tr> and so the table is incomplete.I think this is what Scoutt is saying...

<html>
<head><title>A Sample Login Page</title></head>
<body>
<SCRIPT language="JavaScript" src=http://www.htmlforums.com/archive/index.php/"gulfOwnerTable.js"></SCRIPT>

<? function printLoginForm() {
print <<<HERE
<p>
<form action="login.php" name="loginForm"
method="post" onSubmit="return checkUserAndPass();">
<h2>You much login to view these pages</h2>
<table border="1">
<th colspan="2">LOGIN PAGE!</th>
<tr>
<td>Login:</td>
<td><input type="text" maxlength="10" size="12" name="username" size="7"></td></tr>
<tr>
<td>Password:</td>
<td><input type="password" maxlength="10" size="12" name="password" size="7"></td></tr>
<tr><td colspan="2" align="center"><input type="submit" value="Login!"></td></tr></table>
</form></p>
HERE;}
?>

<?
$loginUserName = $_REQUEST["username"];
$loginPassWord = $_REQUEST["password"];
if((!isset($loginUserName))&&(!isset($loginPassWord))) {
printLoginForm();
print "past the function";
?>

and the way you use your <p> tag is kind of weird... is that necessary? I believe <table> and <h1> and all that creates breaks anyway...No I just stuck the <p> tags in there because I was trying to get a separation between the table and the print out to see if that made a difference. It looks like my main problem was not closing the </table>. I didn't want the print out in the table, but I think the browser was assuming I did because I didn't close the table. I knew it was something ridiculous, thanks guys.
 
Back
Top