NYCPHP Meetup

NYPHP.org

[nycphp-talk] Differing versions of HTML

David Krings ramons at gmx.net
Sun Jan 20 21:18:43 EST 2008


PaulCheung wrote:
> Could anybody suggest where I could find information that will help me 
> overcome this difficulty or let me know the difference in the HTMLs

There is really only one form of (X)HTML and that is the one defined in the 
W3C standard. Submit and clear are the standard submit and reset buttons. I 
would design the Exit button to be a submit button as well, but for a 
different <form> section. The target will be different than the one for the 
real form. The exit form doesn't have any form fields and when the exit script 
is called it forwards the browser back to a main page or where ever the next 
logical position is.
Here is an example of a plain login form with all the XHTML shebang around it. 
Mine is a bit more complicated, but I removed all the bling from it to make it 
even easier.

<?xml version="1.0" encoding="iso-8859-1"?>
<!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" />
   <meta name="generator" content="amaya 9.51, see http://www.w3.org/Amaya/" />
<link href="http://localhost:8080/file:/F:/piviviewer/styles.css" 
rel="stylesheet" type="text/css" /><title>PiViViewer - The Picture and Video 
Viewer</title></head>
<body onload="document.login.username.focus()">

<h1 class="center">Login</h1>

<p></p><p></p><p class="center">Enter no User Name and Password to view public 
content only.</p>
<form name="login" action="logincheck.php" method="POST">
<p>User Name:</p>
<p><input type="text" name="username" /></p>
<p>Password:</p>
<p><input type="password" name="password" /></p><br />
<p><input type="submit" value="Submit" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input 
type="reset" value="Reset" name="Reset" />&nbsp;</p>
</form>

</body>
</html>



So, if you now want to add an exit feature I'd add this

<form name="loginexit" action="loginexit.php" method="POST">
<input type="submit" value="Exit" />
</form>

and in order to make all the buttons show in the same row, it should look like 
this for the sequence Submit - Reset - Exit (stick this into the same spot 
where the <form> ...</form> section is above):

<form name="login" action="logincheck.php" method="POST">
<p>User Name:</p>
<p><input type="text" name="username" /></p>
<p>Password:</p>
<p><input type="password" name="password" /></p><br />
<p><input type="submit" value="Submit" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input 
type="reset" value="Reset" name="Reset" /></form>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<form name="loginexit" action="loginexit.php" 
method="POST">
<input type="submit" value="Exit" />
</form></p>

You see that you can have more than just one form on a page. All this is plain 
standard XHTML and if a browser cannot handle that, uninstall it immediately 
(I know, impossible with IE).


If you want to read up, a quick reference is always http://w3schools.com/ 
otherwise see that you can get the XHTML Definitie Guide from O'Reilly. That 
is what I use since years and it worked out well. If you can get the book 
bundled with the CSS Defintie Guide, go for it.


If all this doesn't work out, post your code so that one can take a look at it.


David



More information about the talk mailing list