views:

232

answers:

6

I need to tweak the web interface of an in-house print system, but it's going on a decade since I touched HTML. Could anyone recommend some tutorials on writing HTML forms and processing them in PHP? Google only gets me eight-year-old resources with big "for historical purposes only" banners on top, possibly because all my vocabulary is eight years old.

The documentation on php.net is good, but I'm looking for larger examples showing how all the pieces fit together, preferably with commentary explaining the programmer's thoughts. I can look up function APIs just as well as the next guy.

Edit: Specifically asking about PHP and HTML forms. Sorry if the title was misleading---I only meant to give a few examples of things I didn't know.

A: 

You might want to check out w3schools.

Chris Kloberdanz
He wants resources that are not 8 years old.
Breton
@Breton, +1 and, also, 'lol' =)
David Thomas
He probably also wants resources aren't full of errors and that don't avoid best practices in all their examples too. W3Schools is awful.
David Dorward
I have only been there a few times and the info was right. So, I guess that wasn't a good enough litmus test.
Chris Kloberdanz
what irks me about w3schools is that the name implies that it's endorsed by the w3c when it is not. This is why trademark law was created guys! I'm not normally a big fan of IP laws, but I wish they'd get applied here.
Breton
Generally it works. "Right" is something else completely.
aehiilrs
@Breton and @aehiilrs: Good points
Chris Kloberdanz
@Breton - I think W3 is too generic (being an abbr of WWW) to be registered as a trademark :(
David Dorward
+2  A: 

Tables were deprecated = Google CSS Layouts

JavaScript has libraries = Google jQuery

Can't help you much on the PHP side of things but that should at least update your "Google Vocabulary"

Dieter G
+2  A: 

I've found that, for when I've forgotten something, Tizag.com to be pretty useful, a simple tutorial -though it is simple, so I don't know how useful it might be to you- is here, at: http://www.tizag.com/phpT/examples/formex.php, which provides a walk-through with some explanation of the choices made.

Javascript libraries,

  1. jQuery.
  2. mootools.
  3. Glow (from the BBC, open source and very backwards-compatible).


Edited in response to comment

More reliable php references to help you get started:

  1. Getting started (php.net)
  2. forms tutorial (as above, at php.net)

The problem I'm finding with php/forms tutorials (outside of books) is that there's some crazy mis-use of -to my mind, ymmv, etc...- xhtml tags inside of forms, completely disregarding the concept of -mentioned elsewhere- semantic (x)html. I think that when reading the tutorials the key is to maintain a critical mind and try to be alert to the ab-, or mis-, uses:

<form action="this_page.php" method="post" enctype="form/multipart">
<p>This is a label <input value="this is the input" /></p>
<p><input type="submit" value="submit" /></p>
</form>

may be valid, but to my mind it's hideously wrong1. I'm amazed that there aren't more easily available and up-to-date resources.


1: To my mind it should be something closer to:

<form action="this_page.php" method="post" enctype="form/multipart">
    <fieldset> // to associate relevant groups of label/input pairs
        <label>This is a label</label> <input value="this is the input" />
    </fieldset>

    <fieldset>
        <input type="submit" value="submit" />
    </fieldset>
</form>
David Thomas
Unfortunately this makes the same mistakes as every other awful beginners' PHP tutorial I've met. Unreadable lack of indentation or differentation between HTML and PHP, HTML laboriously stitched together and echoed instead of using the language's own templating facilities, cross-site-scripting holes caused by lack of htmlspecialchars... I'd love to see a PHP tutorial that doesn't encourage bad practice from the word go.
bobince
You have a valid point; I hadn't realised it was that bad when I recommended it. I'm disturbed by my -apparent- blindness to hideous practice. And -see updated answer- it seems even php.net's manual isn't immune. *weird*
David Thomas
The edited answer that distinguishes between the first, correct example and the second, good example is exactly what I'm looking for. Thanks!
Wang
+6  A: 

let me suggest to you www.alistapart.com. It has eveything about the state of the art of modern HTML and CSS (and some hints on javascript too).

Another very good resource is nettuts

"are you from the past ?"

gpilotino
+1  A: 

I wouldn't say that tables are deprecated, they were just frowned upon as a layout mechanism, due to improvements in CSS. To be honest, i still find them useful for more than just showing tabular data, as the diferent browsers implement CSS differently, so why muck round for hours trying to get some layout right using CSS when a table will do it the same in just minutes, and then you position the table using CSS.... it's a religious war between the purists and the practical people who have real work to do :)

In any case, HTML hasn't really changed that much (it has mainly grown), anything dealing with the HML 4.01 spec is good, and some of the browsers already implement HTML 5 stuff even though it isn't ratified. Any half decent HTML editor should see you right, check out the free (Express) versions of Visual Studio available from Microsoft.

slugster
Sorry, the current HTML version in my reply is wrong, it think it should be 4.2?
slugster
html 4.2 is what douglas crockford thinks we should be doing instead of html5. 4.01 is still current.
Breton
Yes! Tables are still extremely useful for layout in some situations, particularly when trying to vertically center things. Until display:table-cell works reliably in all browsers I'll continue to use them. The css nazis can all look down on me if they wish, but the jokes on them as they spend hours staring at a stylesheet trying to get their floats to go where they want them to.
Rob
*ahem*... it works in all browsers.
Breton
Sure, and in two years when IE6 and IE7 market share isn't over double that of IE8 we can use it somewhat reliably.
Rob
+7  A: 

Tables are only "deprecated" when talking about tables for positioning the elements of the layout (header, menu, content, footer, etc). They are less or more replaced by CSS and HTML block elements (usually the div element is been used). Tables are still useful to display tabular data.

There are indeed more JS libraries out than previously. With jQuery as the topper. Main goal of those is to remove the developer's stress about browser specific behaviours and lengthy/repeated/unintuitive code.

Nowadays HTML is supposed to be purely semantic. CSS is supposed to style and position the HTML elements individually. JS is supposed to add just that extra user experience to the page (to avoid unnecessarily lengthy request-response cycles and "flash of content") and ought to be kept unobtrusive.

PHP is still a server side hypertext processing language. You can use it to pre- and postprocess requests and to control the flow and access the data in the HTML page.

BalusC
I wish I could upvote that first paragraph a million times. I'll never understand the kooks who insist on (poorly) emulating tables with divs.
aehiilrs